<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 --- - eagerly-instantiated entities whose templates are defined after the first point of instantiation don't get instantiated at all" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24128&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=BDub-xVA5CKr0Hpmqh7ZIuvf9qND8rDnr6epbV1KyuY&s=pKkL-sRDalz7cvM-OWODfarWU3qFEHB65TYk0BvVI_k&e=">24128</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>eagerly-instantiated entities whose templates are defined after the first point of instantiation don't get instantiated at all
          </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>richard-llvm@metafoo.co.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>If a template specialization is referenced in a way that requires a definition,
but the definition of the template appears after the use, the instantiation is
never performed.

Examples through the ages:

// C++98:
template<typename T> struct X { static const int n; };
int k = X<int>::n;
template<typename T> const int X<T>::n = 5;

// C++11:
template<typename T> constexpr int f();
int k = f<int>();
template<typename T> constexpr int f() { return 5; }

// C++14:
template<typename T> extern const int n;
int k = n<int>;  
template<typename T> const int n = 5;

These are valid, and should cause the instantiation of the relevant template,
according to C++14 [temp]/6, which requires the template to "be defined in
every translation unit in which it is implicitly instantiated", but doesn't
require the definition to precede the use.</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>