[PATCH] D23719: [libc++] Use C11 for atomics check

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 19 11:22:38 PDT 2016


rsmith added a comment.

In https://reviews.llvm.org/D23719#520954, @bcraig wrote:

> In https://reviews.llvm.org/D23719#520952, @rsmith wrote:
>
> > Are we really guaranteed that the C and C++ compiler behave the same way here? I don't see why that would necessarily be the case.
>
>
> For libc++, std::atomic is implemented in terms of _Atomic.  So as long as the C++ compiler doesn't butcher _Atomic, it seems that the behavior would be the same.


I don't see any good reason to assume that's the case. GCC, for instance, does not define _Atomic *at all* in C++ mode; the implementation used by libc++ in that case is completely different. Also, as far as I know, libc++ did not previously require the host to have a C11 compiler. And there's no reason to assume that the C compiler picked up by cmake is in any way related to the C++ compiler.

Bottom line: if you want to know how the C++ compiler behaves, you need to test the C++ compiler not the C compiler.


https://reviews.llvm.org/D23719





More information about the cfe-commits mailing list