[LLVMbugs] [Bug 19288] New: thread_local member variable accessed without being constructed

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Mar 30 21:32:30 PDT 2014


            Bug ID: 19288
           Summary: thread_local member variable accessed without being
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arturomdn at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

This bug exists in both clang++ and g++ and was first reported in


A simple test case is here


    #include <iostream>
    using namespace std;
    struct foo {
        int i;
        foo(): i{42} {}
    struct bar {
        static thread_local foo FOO;
    thread_local foo bar::FOO;
    int main() {
        //cerr << string((bar::FOO.i == 42) ? "Ok" : "Bug") << endl; //Ok
        cerr << string((bar().FOO.i == 42) ? "Ok" : "Bug") << endl;  //Bug
        return 0;

Invoked as

clang++ -std=c++11 -O2 -Wall -pedantic -pthread main.cpp && ./a.out

Output is

Expected output is

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140331/c5cc5a20/attachment.html>

More information about the llvm-bugs mailing list