简体   繁体   中英

clang 3.2 fails on std::atomic — a libc++ issue?

I try to compile the simple code

#include <atomic>
int bar = 0;
void foo(std::atomic<int>&flag)
{ bar = flag; }

with clang++ 3.2 (downloaded as llvm 3.2 from llvm.org; on mac os.x 10.8.3 this fails with the error

/> clang++ -std=c++11 -stdlib=libc++ -O3 -march=native -c test.cc

In file included from test.cc:1:

/usr/include/c++/v1/atomic:576:17: error: first argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)

 {return __c11_atomic_load(&__a_, __m);} ^ ~~~~~ 

/usr/include/c++/v1/atomic:580:53: note: in instantiation of member function 'std::_ 1:: _atomic_base::load' requested here

 operator _Tp() const _NOEXCEPT {return load();} ^ 

test.cc:5:9: note: in instantiation of member function 'std::_ 1:: _atomic_base::operator int' requested here

 bar = done; 

When I use /usr/bin/clang++ instead (which comes with the OS or Xcode) it compiles just fine. The libc++ is that at /usr/lib/c++/v1 in both cases.

What am I missing? Is there another libc++ that comes with llvm 3.2 but which I'm missing? (I cannot find anything in the clang3.2 tree).

Xcode now bundles libc++ within the Xcode.app directory. You can inspect this directory by control-clicking Xcode.app and choose "Show Package Contents".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM