-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
| Bugzilla Link | 51769 |
| Version | trunk |
| OS | Linux |
| CC | @zygoloid |
Extended Description
[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: https://wandbox.org/permlink/P2GpDGy6mxMydtii)
class A { class B {}; };
template struct S {};
template<> struct S<A::B> {};
int main() {}
(B) (DEMO: https://wandbox.org/permlink/CZFZlMwC3VMzSBky):
class A { class B {}; };
template void foo() {};
template<> void foo<A::B>() {}
int main() {}
(C) (DEMO: https://wandbox.org/permlink/LX3LWSesx2tBCbMh)
class A { class B {}; };
template
constexpr bool v = false;
template<>
constexpr bool v<A::B> = true;
int main() {}
Moreover, program (D) below:
(D) (DEMO: https://wandbox.org/permlink/hjEw0n4UN0wQ55Fv)
class A { class B {}; };
template<typename T, typename U> struct S {};
template struct S<A::B, U> {};
template 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] https://timsong-cpp.github.io/cppwp/n4861/temp.spec#6
[2] P0692R1 - Access Checking on Specializations
http://open-std.org/JTC1/SC22/WG21/docs/papers/2017/p0692r1.html)
[3] https://timsong-cpp.github.io/cppwp/n4861/temp.class.spec#10