<html>
    <head>
      <base href="https://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 --- - ICE when initializing a const class with a class static variable template"
   href="https://llvm.org/bugs/show_bug.cgi?id=31701">31701</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ICE when initializing a const class with a class static variable template
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>charles_li@playstation.sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>We encountered an assertion failure when compiling a test-case with class
static template variables that contains an error.  The crash happens after
an appropriate error message is produced.

This ICE started on revision 245497
$ svn log -r 245497
------------------------------------------------------------------------
r245497 | rsmith | 2015-08-19 13:49:38 -0700 (Wed, 19 Aug 2015) | 2 lines
Internal-linkage variables with constant-evaluatable initializers do not need
to be emitted.
(Also reduces the set of variables that need to be eagerly deserialized when
using PCH / modules.)
------------------------------------------------------------------------

Here is the test case.

$ cat t.cpp
class C {
    template<int i> static int n;
};
template <int M> class D;
template <int M>
template<int i> void D<M>::set() {
    const C c = C::n<i>;
}

Here is the ICE message:

$ clang t.cpp -c
t.cpp:2:32: warning: variable templates are a C++14 extension
[-Wc++14-extensions]
    template<int i> static int n;
                               ^
t.cpp:6:28: error: out-of-line definition of 'set' from class 'D<M>' without
definition
template<int i> void D<M>::set() {
                     ~~~~~~^
clang-4.0: /home/chli/Source/usvn/llvm/tools/clang/lib/AST/Decl.cpp:2164:
clang::APValue*
clang::VarDecl::evaluateValue(llvm::SmallVectorImpl<std::pair<clang::SourceLocation,
clang::PartialDiagnostic> >&) const: Assertion `!Init->isValueDependent()'
failed.

clang-4.0: error: unable to execute command: Aborted (core dumped)
clang-4.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 5.0.0 (trunk 292529)
Target: x86_64-unknown-linux-gnu
Thread model: posix</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>