A simpler example (testing with msys2's gcc 10.2.0/gdb 10.1): #include <cstdio> #include <thread> struct S { long long x; S() : x(0x1234) { printf("S(): this=%p, x=0x%llX\n", this, x); } S(const S &) = delete; ~S() { printf("~S(): this=%p, x=0x%llX\n", this, x); } }; int main() { std::thread([&]() { thread_local S oss; static_cast<void>(oss); // Make sure 'oss' is initialized. }).join(); } Here x in constructor is 0x1234 as expected, but it becomes 0xFEEEFEEEFEEEFEEE before destructor is called,...
Another datapoint: compiled on Ubuntu 20.04 with g++-mingw-w64-x86-64 9.3.0-7ubuntu1+22~exp1ubuntu4 (x86_64-w64-mingw32-g++-posix with -static and -static-libgcc specifically, -win32 version does not support std::thread apparently) , ran on Windows, it crashed on thread termination even without gdb attached.
P.S. Sorry, I've accidentally attached wrong stacktraces for gdb 10/gdb 10, here is a correct one: GNU gdb (GDB) 10.1 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-w64-mingw32". Type "show configuration" for configuration...
thread_local variable crashes std::thread when run under gdb
What about %Lf and long double then? It's defined in C++11 standard, and there is...
%lld works in latest Windows and is specified in C++11 standard, but MinGW still gives warning when -Wformat is enabled