Skip to content

Commit 3ba0a3f

Browse files
committed
GCC fixes
1 parent 1523370 commit 3ba0a3f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

libcxx/include/stdatomic.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,12 @@ using std::atomic_store_explicit _LIBCPP_USING_IF_EXISTS;
231231
using std::atomic_signal_fence _LIBCPP_USING_IF_EXISTS;
232232
using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS;
233233

234-
# else
234+
# elif defined(_LIBCPP_COMPILER_CLANG_BASED)
235235

236236
// Before C++23, we include the next <stdatomic.h> on the path to avoid hijacking
237-
// the header, since Clang and some platforms have been providing this header for
238-
// a long time and users rely on it.
237+
// the header. We do this because Clang has historically shipped a <stdatomic.h>
238+
// header that would be available in all Standard modes, and we don't want to
239+
// break that use case.
239240
# if __has_include_next(<stdatomic.h>)
240241
# include_next <stdatomic.h>
241242
# endif

libcxx/test/libcxx/atomics/stdatomic.h.syn/dont_hijack_header.cxx23.compile.pass.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
// REQUIRES: c++03 || c++11 || c++14 || c++17 || c++20
1919

20+
// On GCC, the compiler-provided <stdatomic.h> is not C++ friendly, so including <stdatomic.h>
21+
// doesn't work at all if we don't use the <stdatomic.h> provided by libc++ in C++23 and above.
22+
// XFAIL: (c++11 || c++14 || c++17 || c++20) && gcc
23+
2024
#include <atomic>
2125
#include <stdatomic.h>
2226
#include <type_traits>

0 commit comments

Comments
 (0)