https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121496
Bug ID: 121496
Summary: [regression] 'class std::timed_mutex' has no member
named '_M_clocklock' with -fsanitize=thread
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: ted at lyncon dot se
Target Milestone: ---
Compile this with `-fsanitize=thread`:
```
#include <chrono>
#include <mutex>
int main() {
std::timed_mutex m;
std::unique_lock<std::timed_mutex> ul{m, std::chrono::steady_clock::now()};
}
```
And you'll get this:
```
In file included from <source>:2:
/opt/compiler-explorer/gcc-14.1.0/include/c++/14.1.0/mutex: In instantiation of
'bool std::__timed_mutex_impl<_Derived>::_M_try_lock_until(const
std::chrono::time_point<std::chrono::_V2::steady_clock, _Duration>&) [with
_Duration = std::chrono::duration<long int, std::ratio<1, 1000000000> >;
_Derived = std::timed_mutex]':
/opt/compiler-explorer/gcc-14.1.0/include/c++/14.1.0/mutex:280:33: required
from 'bool std::timed_mutex::try_lock_until(const
std::chrono::time_point<_Clock, _Duration1>&) [with _Clock =
std::chrono::_V2::steady_clock; _Duration = std::chrono::duration<long int,
std::ratio<1, 1000000000> >]'
280 | { return _M_try_lock_until(__atime); }
| ~~~~~~~~~~~~~~~~~^~~~~~~~~
/opt/compiler-explorer/gcc-14.1.0/include/c++/14.1.0/bits/unique_lock.h:98:37:
required from 'std::unique_lock<_Mutex>::unique_lock(mutex_type&, const
std::chrono::time_point<_Clock, _Duration>&) [with _Clock =
std::chrono::_V2::steady_clock; _Duration = std::chrono::duration<long int,
std::ratio<1, 1000000000> >; _Mutex = std::timed_mutex; mutex_type =
std::timed_mutex]'
98 | _M_owns(_M_device->try_lock_until(__atime))
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
<source>:6:78: required from here
6 | std::unique_lock<std::timed_mutex> ul{m,
std::chrono::steady_clock::now()};
|
^
/opt/compiler-explorer/gcc-14.1.0/include/c++/14.1.0/mutex:205:48: error:
'class std::timed_mutex' has no member named '_M_clocklock'
205 | return
static_cast<_Derived*>(this)->_M_clocklock(CLOCK_MONOTONIC,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
```
Interestingly, clang++, also using libstdc++, gives the same error since
clang++-19. In clang++-18 (with whatever libstdc++ it shipped with) it
compiles.
g++-13.4 seems to compile it, but it gives a runtime error in Compiler
Explorer:
FATAL: ThreadSanitizer: unexpected memory mapping 0x706433672000-0x706433b00000
I assume there was a regression between g++-13.4 and g++-14.1