[temp.expl.spec] p7 merely implicit instantiation?
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
[temp.expl.spec]
If a template, a member template or a member of a class template is explicitly specialized, a declaration of that specialization shall be reachable from every use of that specialization that would cause an implicit instantiation to take place, in every translation unit in which such a use occurs; no diagnostic is required.
Consider the formal example after the above rule
template<class T> struct A {
enum E : T;
enum class S : T;
};
template<> enum A<int>::E : int { eint }; // OK
template<> enum class A<int>::S : int { sint }; // OK
template<class T> enum A<T>::E : T { eT };
template<class T> enum class A<T>::S : T { sT };
template<> enum A<char>::E : char { echar }; // error: A<char>::E was instantiated
// when A<char> was instantiated
template<> enum class A<char>::S : char { schar }; // OK
The remark says the last line is ok. Isn't that A<char> doesn't cause the implicit instantiation of S? As per [temp.inst] p3
The implicit instantiation of a class template specialization causes
- the implicit instantiation of the declarations, but not of the definitions, of the non-deleted class member functions, member classes, scoped member enumerations, static data members, member templates, and friends; and
- the implicit instantiation of the definitions of deleted member functions, unscoped member enumerations, and member anonymous unions.
Hence, presumably, the intent of [temp.expl.spec] p7 does not refer to an arbitrary implicit instantiation. Consider the second case
template<class T> struct A {
enum E : T;
enum class S : T;
};
template<> enum A<int>::E : int { eint }; // OK
template<> enum class A<int>::S : int { sint }; // OK
// template<class T> enum A<T>::E : T { eT }; comment this definition
template<class T> enum class A<T>::S : T { sT };
template<> enum A<char>::E : char { echar }; // OK
template<> enum class A<char>::S : char { schar }; // OK
If we comment the definition of A<T>::E, then the explicit specialization template<> enum A<char>::E : char { echar }; is also ok(both in GCC and Clang). So, Is the following rule the original intent of [temp.expl.spec] p7?
If a template, a member template or a member of a class template is explicitly specialized, a declaration of that specialization shall be reachable from every use of that specialization that would cause an implicit instantiation of the definition to take place and the entity whose specialization is being implicit instantiated has been defined at the point of instantiation, in every translation unit in which such a use occurs; no diagnostic is required.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read [temp.expl.spec] p7 and [temp.inst] p3, then compare both formal examples in the issue with GCC and Clang behavior. Determine whether the proposed wording matches the intended implicit-instantiation rule; the issue is complete when the standard wording and example interpretation are resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100