http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60689
Bug ID: 60689 Summary: Bogus error with atomic::exchange Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: roman at binarylife dot net Host: x86_64-unknown-linux-gnu Target: x86_64-unknown-linux-gnu Build: x86_64-unknown-linux-gnu $ cat test.cc #include <atomic> template<int N> struct X { char stuff[N]; }; template<int N> void test() { X<N> x; std::atomic<X<N>> a; x = a; a.exchange(x); } int main() { test<9>(); return 0; } $ g++ -std=c++11 -O2 -l atomic test.cc In file included from test.cc:1:0: /home/abend/local/gcc-4.9/include/c++/4.9.0/atomic: In instantiation of ‘_Tp std::atomic<_Tp>::exchange(_Tp, std::memory_order) [with _Tp = X<9>; std::memory_order = std::memory_order]’: test.cc:11:3: required from ‘void test() [with int N = 9]’ test.cc:15:11: required from here /home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:225:41: error: invalid conversion from ‘X<9>*’ to ‘long unsigned int’ [-fpermissive] __atomic_exchange(&_M_i, &__i, &tmp, _m); ^ /home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:225:41: error: cannot convert ‘std::memory_order’ to ‘void*’ for argument ‘4’ to ‘void __atomic_exchange(long unsigned int, volatile void*, void*, void*, int)’ $ g++ --version g++ (GCC) 4.9.0 20140327 (experimental) ...