Anyone knows what kind of UB is this? The following code deadlocks on jthread destruction when built with MSVC 19.29.30148, sometimes it deadlocks after std::cout and sometimes before.
This is somehow related to thread_local, but I cannot see what is the issue. It seems to work fine under other compilers and platforms.
#include <thread>
#include <memory>
#include <iostream>
int main(void)
{
std::thread t2(
[&] {
thread_local std::jthread asd([] {
std::cout << "ASD" << std::endl;
});
});
if (t2.joinable()) { t2.join(); }
}
Update: Reproducible both on static and dynamic runtime