Message ID | 20210608002843.945023-1-rodgert@appliantology.com |
---|---|
State | New |
Headers | show |
Series | libstdc++: Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889] | expand |
On Tue, 8 Jun 2021 at 01:29, Thomas Rodgers wrote: > This time without the repeatred [PRnnnn] in the subject line. > > Fixes libstdc++/100889 > This should be part of the ChangeLog entry instead, preceded by PR so it updates bugzilla, i.e. > libstdc++-v3/ChangeLog: > <TAB>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. > OK for trunk and gcc-11 with that change, thanks.
Tested x86_64-pc-linux-gnu, committed to master, backported to releases/gcc-11. On Tue, Jun 8, 2021 at 8:44 AM Jonathan Wakely <jwakely@redhat.com> wrote: > On Tue, 8 Jun 2021 at 01:29, Thomas Rodgers wrote: > >> This time without the repeatred [PRnnnn] in the subject line. >> >> Fixes libstdc++/100889 >> > > This should be part of the ChangeLog entry instead, preceded by PR so it > updates bugzilla, i.e. > > > >> libstdc++-v3/ChangeLog: >> > > <TAB>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. >> > > > OK for trunk and gcc-11 with that change, thanks. > > > >
Hi, On Wed, 9 Jun 2021 at 01:05, Thomas Rodgers via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > Tested x86_64-pc-linux-gnu, committed to master, backported to > releases/gcc-11. > > On Tue, Jun 8, 2021 at 8:44 AM Jonathan Wakely <jwakely@redhat.com> wrote: > > > On Tue, 8 Jun 2021 at 01:29, Thomas Rodgers wrote: > > > >> This time without the repeatred [PRnnnn] in the subject line. > >> > >> Fixes libstdc++/100889 > >> > > > > This should be part of the ChangeLog entry instead, preceded by PR so it > > updates bugzilla, i.e. > > > > > > > >> libstdc++-v3/ChangeLog: > >> > > > > <TAB>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. > >> > > > > > > OK for trunk and gcc-11 with that change, thanks. > > > > This is causing a regression on old arm targets: --target arm-none-linux-gnueabi RUNTESTFLAGS: -march=armv5t FAIL: 29_atomics/atomic_ref/wait_notify.cc (test for excess errors) Excess errors: /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/arm-none-linux-gnueabi/bin/ld: /ccaaHfBz.o: in function `void std::__atomic_impl::store<double>(double*, std::remove_volatile<double>::type, std::memory_order)': /aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-linux-gnueabi/gcc3/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_base.h:971: undefined reference to `__atomic_store_8' /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/arm-none-linux-gnueabi/bin/ld: /ccaaHfBz.o: in function `std::remove_volatile<double>::type std::__atomic_impl::load<double>(double const*, std::memory_order)': /aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-linux-gnueabi/gcc3/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_base.h:979: undefined reference to `__atomic_load_8' /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/arm-none-linux-gnueabi/bin/ld: /aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-linux-gnueabi/gcc3/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_base.h:979: undefined reference to `__atomic_load_8' /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/arm-none-linux-gnueabi/bin/ld: /aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-linux-gnueabi/gcc3/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_base.h:979: undefined reference to `__atomic_load_8' collect2: error: ld returned 1 exit status Can you check? Thanks
Pretty sure I know this is, I'll work on a fix today. On Wed, Jun 9, 2021 at 7:30 AM Christophe Lyon <christophe.lyon@linaro.org> wrote: > Hi, > > > On Wed, 9 Jun 2021 at 01:05, Thomas Rodgers via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > Tested x86_64-pc-linux-gnu, committed to master, backported to > > releases/gcc-11. > > > > On Tue, Jun 8, 2021 at 8:44 AM Jonathan Wakely <jwakely@redhat.com> > wrote: > > > > > On Tue, 8 Jun 2021 at 01:29, Thomas Rodgers wrote: > > > > > >> This time without the repeatred [PRnnnn] in the subject line. > > >> > > >> Fixes libstdc++/100889 > > >> > > > > > > This should be part of the ChangeLog entry instead, preceded by PR so > it > > > updates bugzilla, i.e. > > > > > > > > > > > >> libstdc++-v3/ChangeLog: > > >> > > > > > > <TAB>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. > > >> > > > > > > > > > OK for trunk and gcc-11 with that change, thanks. > > > > > > > > This is causing a regression on old arm targets: > --target arm-none-linux-gnueabi > RUNTESTFLAGS: -march=armv5t > > FAIL: 29_atomics/atomic_ref/wait_notify.cc (test for excess errors) > Excess errors: > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/arm-none-linux-gnueabi/bin/ld: > /ccaaHfBz.o: in function `void > std::__atomic_impl::store<double>(double*, > std::remove_volatile<double>::type, std::memory_order)': > > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-linux-gnueabi/gcc3/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_base.h:971: > undefined reference to `__atomic_store_8' > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/arm-none-linux-gnueabi/bin/ld: > /ccaaHfBz.o: in function `std::remove_volatile<double>::type > std::__atomic_impl::load<double>(double const*, std::memory_order)': > > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-linux-gnueabi/gcc3/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_base.h:979: > undefined reference to `__atomic_load_8' > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/arm-none-linux-gnueabi/bin/ld: > > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-linux-gnueabi/gcc3/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_base.h:979: > undefined reference to `__atomic_load_8' > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/arm-none-linux-gnueabi/bin/ld: > > /aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-linux-gnueabi/gcc3/arm-none-linux-gnueabi/libstdc++-v3/include/bits/atomic_base.h:979: > undefined reference to `__atomic_load_8' > collect2: error: ld returned 1 exit status > > Can you check? > > Thanks > >
For other tests that don't link to libatomic we use if-constexpr to limit which types we test e.g. --- a/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc @@ -33,14 +33,17 @@ template<typename S> S aa{ va }; S bb{ vb }; std::atomic_ref<S> a{ aa }; - a.wait(bb); - std::thread t([&] + if constexpr (std::atomic_ref<S>::is_always_lock_free) { - a.store(bb); - a.notify_one(); - }); - a.wait(aa); - t.join(); + a.wait(bb); + std::thread t([&] + { + a.store(bb); + a.notify_one(); + }); + a.wait(aa); + t.join(); + } } int Alternatively we could add arm*-*-* to the targets in add_options_for_libatomic in testsuite/lib/dg-options.exp
diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h index 029b8ad65a9..20cf1343c58 100644 --- a/libstdc++-v3/include/bits/atomic_base.h +++ b/libstdc++-v3/include/bits/atomic_base.h @@ -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 diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc b/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc index 2fd31304222..2500dddf884 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc @@ -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 () { + 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)); + struct S{ int i; }; - S aa{ 0 }; - S bb{ 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(); + test<S>(S{ 0 }, S{ 42 }); return 0; }