<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - static __thread T* ptr(0); error: initializer for thread-local variable must be a constant expression (while T* ptr = 0 will work)"
   href="http://llvm.org/bugs/show_bug.cgi?id=21690">21690</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>static __thread T* ptr(0); error: initializer for thread-local variable must be a constant expression (while T* ptr = 0 will work)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>david.abdurachmanov@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I bumped Clang to pre-3.6 (65d8b4c4998b3a0c20934ea72ede72ef4838a004, r222081,
~15 Nov). Have not checked the trunk version.

$ cat test.cc
template <typename T>
void dummy() {
 static __thread T* ptr(0);
}

$ clang++ -std=c++11 test.cc
test.cc:3:25: error: initializer for thread-local variable must be a constant
expression
 static __thread T* ptr(0);
                       ^~~
test.cc:3:22: note: use 'thread_local' to allow this
 static __thread T* ptr(0);
                    ^
1 error generated.

The following will work:

static __thread T* ptr;
static __thread T* ptr = 0;
static __thread T* ptr = nullptr;
static thread_local T* ptr(nullptr);

The following will not work:

static __thread T* ptr{0};
static __thread T* ptr(0);

It works with c-like initialization, but not with constructor initialization or
uniform initialization.

We are assigning initial value of pointer (nullptr), isn't nullptr/0 are
constant expression here?</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>