Posts

Showing posts with the label clang

`std::call_once` always segfaults on Clang 12 on Windows (when using libstdc++)

10 1 I'm looking for a workaround, which will probably involve patching libstdc++ headers. Preserving binary compatibility is preferred but not obligatory, since I'm not using any precompiled C++ code except libstdc++. I want to keep the std::call_once interface, since I'm trying to compile third-party code that uses is, which I don't want to change. Here's my code: #include <iostream> #include <mutex> int main() { std::once_flag flag; std::call_once(flag, []{std::cout << "Once!\n";}); } Running it causes a segmentation fault. I cross-compile it to Windows from Ubuntu using Clang 12, using the standard library from MSYS2 GCC 10.2. Then I test the result with Wine (a quick test showed that it crashes on a VM...