Re: [PATCH] libstdc++: Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889]

2021-06-09 Thread Jonathan Wakely via Gcc-patches
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
S aa{ va };
S bb{ vb };
std::atomic_ref a{ aa };
-a.wait(bb);
-std::thread t([&]
+if constexpr (std::atomic_ref::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



Re: [PATCH] libstdc++: Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889]

2021-06-09 Thread Thomas Rodgers via Gcc-patches
Pretty sure I know this is, I'll work on a fix today.

On Wed, Jun 9, 2021 at 7:30 AM Christophe Lyon 
wrote:

> Hi,
>
>
> On Wed, 9 Jun 2021 at 01:05, Thomas Rodgers via Gcc-patches
>  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 
> wrote:
> >
> > > On Tue, 8 Jun 2021 at 01:29, Thomas Rodgers wrote:
> > >
> > >> This time without the repeatred [PR] 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:
> > >>
> > >
> > > 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*,
> std::remove_volatile::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::type
> std::__atomic_impl::load(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
>
>


Re: [PATCH] libstdc++: Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889]

2021-06-09 Thread Christophe Lyon via Gcc-patches
Hi,


On Wed, 9 Jun 2021 at 01:05, Thomas Rodgers via Gcc-patches
 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  wrote:
>
> > On Tue, 8 Jun 2021 at 01:29, Thomas Rodgers wrote:
> >
> >> This time without the repeatred [PR] 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:
> >>
> >
> > 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*,
std::remove_volatile::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::type
std::__atomic_impl::load(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


Re: [PATCH] libstdc++: Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889]

2021-06-08 Thread Thomas Rodgers via Gcc-patches
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  wrote:

> On Tue, 8 Jun 2021 at 01:29, Thomas Rodgers wrote:
>
>> This time without the repeatred [PR] 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:
>>
>
> 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.
>
>
>
>


Re: [PATCH] libstdc++: Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889]

2021-06-08 Thread Jonathan Wakely via Gcc-patches
On Tue, 8 Jun 2021 at 01:29, Thomas Rodgers wrote:

> This time without the repeatred [PR] 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:
>

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.


[PATCH] libstdc++: Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889]

2021-06-07 Thread Thomas Rodgers
This time without the repeatred [PR] in the subject line.

Fixes libstdc++/100889

libstdc++-v3/ChangeLog:

* 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.
---
 libstdc++-v3/include/bits/atomic_base.h   |  2 +-
 .../29_atomics/atomic_ref/wait_notify.cc  | 38 ---
 2 files changed, 26 insertions(+), 14 deletions(-)

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 
 
+template
+  void
+  test (S va, S vb)
+  {
+S aa{ va };
+S bb{ vb };
+std::atomic_ref a{ aa };
+a.wait(bb);
+std::thread t([&]
+  {
+a.store(bb);
+a.notify_one();
+  });
+a.wait(aa);
+t.join();
+  }
+
 int
 main ()
 {
+  test(0, 42);
+  test(0, 42);
+  test(0u, 42u);
+  test(0.0f, 42.0f);
+  test(0.0, 42.0);
+  test(nullptr, reinterpret_cast(42));
+
   struct S{ int i; };
-  S aa{ 0 };
-  S bb{ 42 };
-
-  std::atomic_ref 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{ 0 }, S{ 42 });
   return 0;
 }
-- 
2.26.2



[PATCH] libstdc++: Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889] [PR100889]

2021-06-07 Thread Thomas Rodgers
Fixes libstdc++/100889

libstdc++-v3/ChangeLog:

* 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.
---
 libstdc++-v3/include/bits/atomic_base.h   |  2 +-
 .../29_atomics/atomic_ref/wait_notify.cc  | 38 ---
 2 files changed, 26 insertions(+), 14 deletions(-)

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 
 
+template
+  void
+  test (S va, S vb)
+  {
+S aa{ va };
+S bb{ vb };
+std::atomic_ref a{ aa };
+a.wait(bb);
+std::thread t([&]
+  {
+a.store(bb);
+a.notify_one();
+  });
+a.wait(aa);
+t.join();
+  }
+
 int
 main ()
 {
+  test(0, 42);
+  test(0, 42);
+  test(0u, 42u);
+  test(0.0f, 42.0f);
+  test(0.0, 42.0);
+  test(nullptr, reinterpret_cast(42));
+
   struct S{ int i; };
-  S aa{ 0 };
-  S bb{ 42 };
-
-  std::atomic_ref 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{ 0 }, S{ 42 });
   return 0;
 }
-- 
2.26.2



[PATCH] [libstdc++] Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889]

2021-06-04 Thread Thomas Rodgers
Fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100889

libstdc++-v3/ChangeLog:

* include/bits/atomic_base.h (atomic_ref<_Tp*>::wait):
Change parameter type from _Tp to _Tp*.
* testsuite/29_atomics/atomic_ref/100889.cc: New test.
---
 libstdc++-v3/include/bits/atomic_base.h   |  2 +-
 .../testsuite/29_atomics/atomic_ref/100889.cc | 29 +++
 2 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 libstdc++-v3/testsuite/29_atomics/atomic_ref/100889.cc

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/100889.cc 
b/libstdc++-v3/testsuite/29_atomics/atomic_ref/100889.cc
new file mode 100644
index 000..1ea58cb6947
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/100889.cc
@@ -0,0 +1,29 @@
+// Copyright (C) 2019-2021 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// .
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include 
+
+void
+test01()
+{
+  void* p;
+  std::atomic_ref a(p);
+  a.store(nullptr);
+}
-- 
2.26.2