[Bug libstdc++/105934] [9/10/11/12/13 Regression] C++11 pointer versions of atomic_fetch_add missing because of P0558

2022-06-13 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105934

Jonathan Wakely  changed:

   What|Removed |Added

  Known to work||8.5.0
  Known to fail||10.3.0, 11.2.0, 12.0, 9.1.0

--- Comment #4 from Jonathan Wakely  ---
I've raised this for discussion with LWG.

FWIW libc++ and MSVC reject the example too. It looks like everybody treats
P0558 as a DR.

It's valid as C++11 and C++17, with old and new implementations, if changed to
use std::atomic_fetch_add(static_cast*>(*ap), 1); }
i.e. using an explicit conversion instead of an explicit template argument
list.

[Bug libstdc++/105934] [9/10/11/12/13 Regression] C++11 pointer versions of atomic_fetch_add missing because of P0558

2022-06-13 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105934

--- Comment #3 from Jonathan Wakely  ---
Created attachment 53127
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53127=edit
Restore atomic_fetch_{add,sub} partial specializations for pointers

This patch restores the partial specializations for pointers for C++11 and
C++14 modes. It also changes the atomic::value_type parameters to use
type_identity_t instead, which avoids the problematic instantiation of
atomic>. This fixes both issues described above.

[Bug libstdc++/105934] [9/10/11/12/13 Regression] C++11 pointer versions of atomic_fetch_add missing because of P0558

2022-06-13 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105934

--- Comment #2 from Jonathan Wakely  ---
Somewhat related:

The MSVC testsuite has an example using atomic_store that fails with
libstdc++:

https://github.com/microsoft/STL/blob/main/tests/std/tests/Dev11_1066589_shared_ptr_atomic_deadlock/test.cpp

atomic_store(shared_ptr, shared_ptr) gives an error
outside the immediate context, because the typename atomic::value_type
parameter causes instantiation of atomic> which is ill-formed.

I think MSVC has some workaround for this, which deviates from what P0558 did.

[Bug libstdc++/105934] [9/10/11/12/13 Regression] C++11 pointer versions of atomic_fetch_add missing because of P0558

2022-06-13 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105934

--- Comment #1 from Jonathan Wakely  ---
I think this is actually expected post-P0558, and I would prefer to treat that
paper as a DR, because the original spec for the atomic_xxx free functions was
weird and inconsistent. The partial specializations for pointer types are
explicitly called out in P0558 as being broken (by allowing arithmetic on types
like atomic and atomic).

Those free functions exist to allow writing code that is valid in both C and
C++, so I don't see much motivation for supporting C++-specific syntax like
explicit template arguments.