// { dg-do run { target c++20 } } // { dg-require-effective-target libatomic_available } // { dg-additional-options "[atomic_link_flags [get_multilibs]] -latomic" } #include #include #include long double zld(10.5); constexpr std::atomic cld(10.5); std::atomic gld(10.5); template void test_floating(std::atomic& g, const T& zp) { T const d = T(7.5); T t; std::memcpy(&t, &zp, sizeof(T)); VERIFY( g.compare_exchange_strong(t, d) ); static std::atomic st(T(10.5)); std::memcpy(&t, &zp, sizeof(T)); VERIFY( st.compare_exchange_strong(t, d) ); thread_local std::atomic tl(T(10.5)); std::memcpy(&t, &zp, sizeof(T)); VERIFY( tl.compare_exchange_strong(t, d) ); std::atomic l(T(10.5)); std::memcpy(&t, &zp, sizeof(T)); VERIFY( l.compare_exchange_strong(t, d) ); std::atomic* h = new std::atomic(T(10.5)); std::memcpy(&t, &zp, sizeof(T)); VERIFY( h->compare_exchange_strong(t, d) ); delete h; constexpr std::atomic cl(T(10.5)); } int main() { test_floating(gld, zld); }