<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 - Unclear error message"
   href="https://bugs.llvm.org/show_bug.cgi?id=51767">51767</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Unclear error message
          </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>Windows NT
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jvapen@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Reproduction: <a href="https://compiler-explorer.com/z/T3Yx33j3v">https://compiler-explorer.com/z/T3Yx33j3v</a>

t.cpp
=====
// clang++ -std=c++20 t.cpp
namespace NS {
template <typename T> class C {};
} // namespace NS

namespace NS::Sub {
template class NS::C<int>;
}


result:
=======
<source>:6:20: error: explicit instantiation of 'C' not in a namespace
enclosing 'NS'
template class NS::C<int>;
                   ^
<source>:2:29: note: explicit instantiation refers here
template <typename T> class C {};
                            ^
1 error generated.


Expected:
=========
In our code, this got triggered via some macro's and the explicit instantiation
happened in a different file than the template. Given some layers of
indirection, this isn't that obvious to people not familiar with the specifics.
Expected message should include the namespace the compiler does deduce for the
instantiation, for example:
explicit instantiation of 'C' happens in namespace 'NS::Sub::NS' while only
allowed in namespace 'NS'</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>