<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - __thread in template does not compile"
   href="https://bugs.llvm.org/show_bug.cgi?id=35237">35237</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__thread in template does not compile
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>oranevskyy@accesssoftek.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>test.cpp:
template<typename T>
void test()
{
  static __thread T my(555);
}

void foo()
{
  test<int>();
}

Compilation:
clang++ -c -std=c++11 test.cpp

Output:
test.cpp:4:23: error: initializer for thread-local
      variable must be a constant expression
  static __thread T my(555);
                      ^~~~~
test.cpp:4:21: note: use 'thread_local' to allow
      this
  static __thread T my(555);

Gcc compiles this with no error. 

As T is a dependent type clang does not "unfold" the ParenListExpr and treats
it as an initializer, i.e.
`-ParenListExpr 0xb40b31c650 <col:23, col:27> 'NULL TYPE'
  `-IntegerLiteral 0xb40b31c5f8 <col:24> 'int' 555

Expr::isConstantInitializer() considers such expressions as non-const, hence
the error.</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>