<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 - [P0692R1] Access checking not waived for declarations of explicit specializations of function and variable templates"
   href="https://bugs.llvm.org/show_bug.cgi?id=51769">51769</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[P0692R1] Access checking not waived for declarations of explicit specializations of function and variable templates
          </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>Keywords</th>
          <td>invalid-bug
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>C++2a
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>[temp.spec]/6[1] was added to the C++20 spec by implementation of P0692R1[2]:

"The usual access checking rules do not apply to names in a declaration of an
explicit instantiation or explicit specialization, with the exception of names
appearing in a function body, default argument, base-clause,
member-specification, enumerator-list, or static data member or variable
template initializer."

Meaning that programs (A) through (C) below are (arguably) well-formed:

(A) (DEMO: <a href="https://wandbox.org/permlink/P2GpDGy6mxMydtii">https://wandbox.org/permlink/P2GpDGy6mxMydtii</a>)

 class A { class B {}; };

 template<typename T> struct S {};
 template<> struct S<A::B> {};

 int main() {}


(B) (DEMO: <a href="https://wandbox.org/permlink/CZFZlMwC3VMzSBky">https://wandbox.org/permlink/CZFZlMwC3VMzSBky</a>):

 class A { class B {}; };

 template<typename T> void foo() {};
 template<> void foo<A::B>() {}

 int main() {}


(C) (DEMO: <a href="https://wandbox.org/permlink/LX3LWSesx2tBCbMh">https://wandbox.org/permlink/LX3LWSesx2tBCbMh</a>)

 class A { class B {}; };

 template<typename T>
 constexpr bool v = false;

 template<>
 constexpr bool v<A::B> = true;

 int main() {}


Moreover, program (D) below:

(D) (DEMO: <a href="https://wandbox.org/permlink/hjEw0n4UN0wQ55Fv">https://wandbox.org/permlink/hjEw0n4UN0wQ55Fv</a>)

 class A { class B {}; };

 template<typename T, typename U> struct S {};
 template<typename U> struct S<A::B, U> {};
 template<typename T> struct S<T, A::B> {};

 int main() {}


is also (arguably) well-formed as per [temp.class.spec]/10[3], which covers
waiving of access checking for template arguments in the simple-template-id of
partial specializations, a paragraph that was also added as part of P0692R1.

However whilst Clang accepts (A), it rejects (B) through (D).

As per [4], the implementation status of P0692R1 is "partial" (so this may
actually not be a bug report but an enhancement request).

---

[1] <a href="https://timsong-cpp.github.io/cppwp/n4861/temp.spec#6">https://timsong-cpp.github.io/cppwp/n4861/temp.spec#6</a>

[2] P0692R1 - Access Checking on Specializations
<a href="http://open-std.org/JTC1/SC22/WG21/docs/papers/2017/p0692r1.html">http://open-std.org/JTC1/SC22/WG21/docs/papers/2017/p0692r1.html</a>)

[3] <a href="https://timsong-cpp.github.io/cppwp/n4861/temp.class.spec#10">https://timsong-cpp.github.io/cppwp/n4861/temp.class.spec#10</a>

[4] <a href="https://clang.llvm.org/cxx_status.html">https://clang.llvm.org/cxx_status.html</a></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>