[cfe-dev] [PATCH] libc++: help diagnosing the following std::atomic compile error

John McCall rjmccall at apple.com
Wed May 22 15:01:46 PDT 2013


On May 22, 2013, at 2:49 AM, Stephan Tolksdorf <st at quanttec.com> wrote:
> On 22.05.13 01:04, Howard Hinnant wrote:
>> I recommend filing a bug against clang on this.  I am hesitant to commit the libc++ fix due to David Chisnall's concerns.  If the clang team reassigns the bug to libc++, then I will commit the libc++ solution.
>> 
> 
> In case anyone has missed the previous reference to http://llvm.org/bugs/show_bug.cgi?id=16056 and is considering a decision on how to proceed, I'd like to describe the consequence of that issue for the current _Atomic-based implementation of <atomic>:
> 
> If you initialize a static atomic variable with a constant expression (e.g. for some kind of lazy initialization scheme), your value is not constant initialized as expected but instead is dynamically initialized at program startup (because clang currently doesn't treat _Atomic(T) as a literal type). This may make your code vulnerable to the infamous "static initialization order fiasco", which can result in difficult to find bugs.

That seems fixable;  _Atomic(T) should be a literal type if T is.

John.



More information about the cfe-dev mailing list