Clang 14's <stdatomic.h>
is incompatible with MSVC's <stdatomic.h>
☢️ · Issue #2862 · microsoft/STL (original) (raw)
This repros with Clang 14, when the STL's tests are compiled with the official toolset (instead of the microsoft/STL repo - the difference is in the header locations, because Clang overrides toolset headers).
tests/std/tests/P0943R6_stdatomic_h/test.compile.pass.cpp
and the many tests including stl/inc/__msvc_all_public_headers.hpp
fail due to Clang's <stdatomic.h>
, like this:
RUN.PM line 750: Executing: "clang-cl -m32 /nologo /Od /W4 /w14061 /w14242 /w14265 /w14582 /w14583 /w14587 /w14588 /w14749 /w14841 /w14842 /w15038 /w15214 /w15215 /w15216 /w15217 /sdl /WX /Zc:strictStrings /D_ENABLE_STL_INTERNAL_CHECK /bigobj /FIforce_include.hpp /w14365 /D_ENFORCE_FACET_SPECIALIZATIONS=1 /D_STL_CALL_ABORT_INSTEAD_OF_INVALID_PARAMETER -fno-ms-compatibility -fno-delayed-template-parsing /EHsc /MD /std:c++14 /w14640 /Zc:threadSafeInit- .\test.cpp /c".
In file included from .\test.cpp:4:
In file included from D:\Contest\ca1z2udg.zif\binaries\x86chk\inc\__msvc_all_public_headers.hpp:146:
D:\Contest\ca1z2udg.zif\src\tools\LLVM\LLVM14\x86\lib\clang\14.0.5\include\stdatomic.h(70,6): error: conflicting types for 'atomic_thread_fence'
void atomic_thread_fence(memory_order);
^
D:\Contest\ca1z2udg.zif\binaries\x86chk\inc\atomic(166,24): note: previous definition is here
extern "C" inline void atomic_thread_fence(const memory_order _Order) noexcept {
^
[...]
As a workaround, we're going to avoid including <stdatomic.h>
for Clang, but solving the root cause would be better.