https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105934

            Bug ID: 105934
           Summary: [9/10/11/12/13 Regression] C++11 pointer versions of
                    atomic_fetch_add missing because of P0558
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hstong at ca dot ibm.com
  Target Milestone: ---

P0558 removed the "pointer specializations" of `atomic_fetch_add`.

The replacements are not call-compatible for calls that use explicit template
arguments to guide conversions.

https://godbolt.org/z/aTT9EdP93

### SOURCE (<stdin>):
#include <atomic>
struct A { template <typename T> operator std::atomic<T *> *(); };
int *f(A *ap) { return std::atomic_fetch_add<int>(*ap, 1); }

### COMPILER INVOCATION:
g++ -fsyntax-only -std=c++11 -xc++ -

### ACTUAL OUTPUT:
<stdin>: In function 'int* f(A*)':
<stdin>:3:50: error: no matching function for call to
'atomic_fetch_add<int>(A&, int)'
In file included from <stdin>:1:
/opt/wandbox/gcc-head/include/c++/13.0.0/atomic:1525:5: note: candidate: '_ITp
std::atomic_fetch_add(atomic<_ITp>*, __atomic_diff_t<_ITp>) [with _ITp = int;
__atomic_diff_t<_ITp> = int]'
 1525 |     atomic_fetch_add(atomic<_ITp>* __a,
      |     ^~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/13.0.0/atomic:1525:36: note:   no known
conversion for argument 1 from 'A' to 'std::atomic<int>*'
 1525 |     atomic_fetch_add(atomic<_ITp>* __a,
      |                      ~~~~~~~~~~~~~~^~~
/opt/wandbox/gcc-head/include/c++/13.0.0/atomic:1531:5: note: candidate: '_ITp
std::atomic_fetch_add(volatile atomic<_ITp>*, __atomic_diff_t<_ITp>) [with _ITp
= int; __atomic_diff_t<_ITp> = int]'
 1531 |     atomic_fetch_add(volatile atomic<_ITp>* __a,
      |     ^~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/13.0.0/atomic:1531:45: note:   no known
conversion for argument 1 from 'A' to 'volatile std::atomic<int>*'
 1531 |     atomic_fetch_add(volatile atomic<_ITp>* __a,
      |                      ~~~~~~~~~~~~~~~~~~~~~~~^~~

### EXPECTED OUTPUT:
Clean compile

### COMPILER VERSION INFO (g++ -v):
Using built-in specs.
COLLECT_GCC=/opt/wandbox/gcc-head/bin/g++
COLLECT_LTO_WRAPPER=/opt/wandbox/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../source/configure --prefix=/opt/wandbox/gcc-head
--enable-languages=c,c++ --disable-multilib --without-ppl --without-cloog-ppl
--enable-checking=release --disable-nls --enable-lto
LDFLAGS=-Wl,-rpath,/opt/wandbox/gcc-head/lib,-rpath,/opt/wandbox/gcc-head/lib64,-rpath,/opt/wandbox/gcc-head/lib32
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20220611 (experimental) (GCC)

Reply via email to