libstdc++: Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889]
libstdc++-v3/ChangeLog: PR libstdc++/100889 * include/bits/atomic_base.h (atomic_ref<_Tp*>::wait): Change parameter type from _Tp to _Tp*. * testsuite/29_atomics/atomic_ref/wait_notify.cc: Extend coverage of types tested.
This commit is contained in:
parent
16a8e18858
commit
25e5ecdf82
2 changed files with 26 additions and 14 deletions
|
@ -1870,7 +1870,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
#if __cpp_lib_atomic_wait
|
||||
_GLIBCXX_ALWAYS_INLINE void
|
||||
wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept
|
||||
wait(_Tp* __old, memory_order __m = memory_order_seq_cst) const noexcept
|
||||
{ __atomic_impl::wait(_M_ptr, __old, __m); }
|
||||
|
||||
// TODO add const volatile overload
|
||||
|
|
|
@ -26,22 +26,34 @@
|
|||
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
template<typename S>
|
||||
void
|
||||
test (S va, S vb)
|
||||
{
|
||||
S aa{ va };
|
||||
S bb{ vb };
|
||||
std::atomic_ref<S> a{ aa };
|
||||
a.wait(bb);
|
||||
std::thread t([&]
|
||||
{
|
||||
a.store(bb);
|
||||
a.notify_one();
|
||||
});
|
||||
a.wait(aa);
|
||||
t.join();
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
struct S{ int i; };
|
||||
S aa{ 0 };
|
||||
S bb{ 42 };
|
||||
test<int>(0, 42);
|
||||
test<long>(0, 42);
|
||||
test<unsigned>(0u, 42u);
|
||||
test<float>(0.0f, 42.0f);
|
||||
test<double>(0.0, 42.0);
|
||||
test<void*>(nullptr, reinterpret_cast<void*>(42));
|
||||
|
||||
std::atomic_ref<S> a{ aa };
|
||||
VERIFY( a.load().i == aa.i );
|
||||
a.wait(bb);
|
||||
std::thread t([&]
|
||||
{
|
||||
a.store(bb);
|
||||
a.notify_one();
|
||||
});
|
||||
a.wait(aa);
|
||||
t.join();
|
||||
struct S{ int i; };
|
||||
test<S>(S{ 0 }, S{ 42 });
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue