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

            Bug ID: 102994
           Summary: std::atomic<ptr>::wait is not marked const
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc_bugzilla at axeitado dot com
  Target Milestone: ---

This code fails to compile because the `wait' member function is not marked
`const' in the specialization of std::atomic for pointers:

#include <atomic>

void foo(const std::atomic<char*> &a, char *p) {
    a.wait(p);
}


g++ --std=c++20

<source>: In function 'void foo(const std::atomic<char*>&, char*)':
<source>:4:11: error: passing 'const std::atomic<char*>' as 'this' argument
discards qualifiers [-fpermissive]
    4 |     a.wait(p);
      |     ~~~~~~^~~
In file included from <source>:1:
/opt/compiler-explorer/gcc-trunk-20211028/include/c++/12.0.0/atomic:651:5:
note:   in call to 'void
std::atomic<_Tp*>::wait(std::atomic<_Tp*>::__pointer_type, std::memory_order)
[with _Tp = char; std::atomic<_Tp*>::__pointer_type = char*]'
  651 |     wait(__pointer_type __old, memory_order __m = memory_order_seq_cst)
noexcept
      |     ^~~~
Compiler returned: 1
  • [Bug libstdc++/102994] New: ... gcc_bugzilla at axeitado dot com via Gcc-bugs

Reply via email to