This is rejected because the atomic operations only accept std::atomic<T> not the std::__atomic_base<T> base classes: #ifdef __cplusplus #include <atomic> using namespace std; #else #include <stdatomic.h> #endif atomic_int i; int main() { atomic_store(&i, 0); return atomic_load(&i); }
Additionally, we fail to meet this requirement: 29.6.2 Templated operations on atomic types [atomics.types.operations.templ] The implementation shall declare but not define the function templates identified as “templated operations on atomic types” in 29.2. We only declare those functions templates when they need to be defined, i.e. for arguments of type __atomic_base or atomic<T*>. The declarations would need to be constrained with SFINAE to prevent them being used for types derived from __atomic_base.
Author: redi Date: Sat Jan 17 01:23:28 2015 New Revision: 219790 URL: https://gcc.gnu.org/viewcvs?rev=219790&root=gcc&view=rev Log: PR libstdc++/60940 * include/bits/atomic_base.h: Remove atomic integral typedefs as synonyms for __atomic_base<int> etc. * include/std/atomic: Make atomic_int a synonym for atomic<int> and likewise for all atomic integral types. * testsuite/29_atomics/atomic_integral/cons/copy_list.cc: New. * testsuite/29_atomics/atomic/60695.cc: Adjust dg-error line number. Added: trunk/libstdc++-v3/testsuite/29_atomics/atomic_integral/60940.cc - copied, changed from r219785, trunk/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/bits/atomic_base.h trunk/libstdc++-v3/include/std/atomic trunk/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc
Fixed for GCC 5