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

            Bug ID: 100889
           Summary: Wrong param type for std::atomic_ref<_Tp*>::wait
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: richardpku at gmail dot com
  Target Milestone: ---

/tmp % cat a.cpp
#include <atomic>
void* p;
void foo() { std::atomic_ref(p).store(nullptr); }

/tmp % g++-11.1.0 -c -std=gnu++20 a.cpp
In file included from
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include/g++-v11/atomic:41,
                 from a.cpp:1:
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include/g++-v11/bits/atomic_base.h: In
instantiation of 'struct std::__atomic_ref<void*, false, false>':
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include/g++-v11/atomic:1618:12:  
required from 'struct std::atomic_ref<void*>'
a.cpp:3:31:   required from here
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include/g++-v11/bits/atomic_base.h:1873:7:
error: invalid parameter type 'void'
 1873 |       wait(_Tp __old, memory_order __m = memory_order_seq_cst) const
noexcept
      |       ^~~~
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include/g++-v11/bits/atomic_base.h:1873:7:
error: in declaration 'void std::__atomic_ref<_Tp*, false, false>::wait(_Tp,
std::memory_order) const'


Apparently, the first param of std::atomic<_Tp*>::wait should be _Tp* instead
of _Tp.

It appears this bug has existed since GCC 11, when __cpp_lib_atomic_wait was
implemented.

Reply via email to