/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.
Created attachment 50917 [details] Proposed patch This patch fixes the problem.
The master branch has been updated by Thomas Rodgers <rodgertq@gcc.gnu.org>: https://gcc.gnu.org/g:25e5ecdf82b49977e86bfaded236fb34af2705ed commit r12-1312-g25e5ecdf82b49977e86bfaded236fb34af2705ed Author: Thomas Rodgers <rodgert@appliantology.com> Date: Tue Jun 8 15:51:53 2021 -0700 libstdc++: Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889] 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.
The releases/gcc-11 branch has been updated by Thomas Rodgers <rodgertq@gcc.gnu.org>: https://gcc.gnu.org/g:d7462945387b33744f665d1aa33ba1cec79c03b0 commit r11-8528-gd7462945387b33744f665d1aa33ba1cec79c03b0 Author: Thomas Rodgers <rodgert@appliantology.com> Date: Tue Jun 8 15:51:53 2021 -0700 libstdc++: Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889] 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. (cherry picked from commit 25e5ecdf82b49977e86bfaded236fb34af2705ed)
Fixed in master, backported to releases/gcc-11