Closed
Description
Description
Using the C-style _Atomic
type in a C++ file fails to compile with NDK r21, but compiles fine with r20 and on other platforms.
test.cpp:
#include <stdatomic.h>
void test() {
_Atomic int p;
atomic_load_explicit(&p, memory_order_relaxed);
}
Error:
test.cpp:5:2: error: no matching function for call to 'atomic_load_explicit'
atomic_load_explicit(&p, memory_order_relaxed);
^~~~~~~~~~~~~~~~~~~~
/Users/me/Library/Android/sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/atomic:1816:1: note: candidate template ignored: could not match 'atomic<type-parameter-0-0>' against '_Atomic(int) *'
atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
^
/Users/me/Library/Android/sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/atomic:1825:1: note: candidate template ignored: could not match 'atomic<type-parameter-0-0>' against '_Atomic(int) *'
atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
^
I think the issue is caused by the same change in bionic as #1177.
This e.g. causes the swift-corelibs-libdispatch project to fail to compile with r21 due to its use of atomic types in atomic.h, which is used in C++.
Environment Details
- NDK Version: 21.0.6113669
- Build system: manually running clang++
- Host OS: macOS
- ABI: any
- NDK API level: any