Ibr*_*iev 13 c++ multithreading msvcrt compiler-bug c++20
有谁知道这是什么类型的UB吗?使用 MSVC 19.29.30148 构建时,以下代码在jthread销毁时死锁,有时在 std::cout 之后死锁,有时在之前死锁。这在某种程度上与 thread_local 有关,但我看不出问题是什么。它似乎在其他编译器和平台下工作得很好。
#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(); }
}
Run Code Online (Sandbox Code Playgroud)
更新:在静态和动态运行时均可重现
| 归档时间: |
|
| 查看次数: |
362 次 |
| 最近记录: |