This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/64658] std::atomic_init() undefined
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 18 Jan 2015 17:22:44 +0000
- Subject: [Bug libstdc++/64658] std::atomic_init() undefined
- Auto-submitted: auto-generated
- References: <bug-64658-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64658
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-01-18
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Although atomic_init doesn't need to be atomic the simplest way to implement it
is just with a relaxed store:
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -921,11 +921,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _ITp>
inline void
- atomic_init(atomic<_ITp>* __a, _ITp __i) noexcept;
+ atomic_init(atomic<_ITp>* __a, _ITp __i) noexcept
+ { __a->store(__i, memory_order_relaxed); }
template<typename _ITp>
inline void
- atomic_init(volatile atomic<_ITp>* __a, _ITp __i) noexcept;
+ atomic_init(volatile atomic<_ITp>* __a, _ITp __i) noexcept
+ { __a->store(__i, memory_order_relaxed); }
template<typename _ITp>
inline void
A better implementation would make atomic_init friend of std::atomic so it can
set the private data member directly.