cplusplus / CWG

Core Working Group
23 stars 7 forks source link

CWG2884 [dcl.type.elab] Qualified declarations of partial specializations #521

Open sdkrystian opened 3 months ago

sdkrystian commented 3 months ago

Full name of submitter (unless configured in github; will be published with the issue): Krystian Stasiowski

Reference (section label): [dcl.type.elab]

Link to reflector thread (if any): N/A

Issue description:

[dcl.type.elab] p2 states:

If an elaborated-type-specifier is the sole constituent of a declaration, the declaration is ill-formed unless it is an explicit specialization, an explicit instantiation or it has one of the following forms:

class-key attribute-specifier-seq(opt) identifier ;
class-key attribute-specifier-seq(opt) simple-template-id ;

In the first case, the elaborated-type-specifier declares the identifier as a class-name. The second case shall appear only in an explicit-specialization or in a template-declaration (where it declares a partial specialization}.

Consider the following:

namespace N
{
    template<typename T>
    struct A;
}

template<>
struct N::A<int>; // #1

template<typename T>
struct N::A<T*>; // #2

The current wording permits the elaborated-type-specifier of #1 to contain a nested-name-specifier. However, #2 is ill-formed because it:

Clang, GCC, EDG, and MSVC all accept the declaration of #2. Presumably, this is an oversight in the wording.

Suggested resolution:

Modify [dcl.type.elab] p2 as follows:

If an elaborated-type-specifier is the sole constituent of a declaration, the declaration is ill-formed unless it is an explicit specialization, a partial specialization, an explicit instantiation or it has one of the following forms [...]

jensmaurer commented 2 months ago

CWG2884