Skip to content

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

Description

@sdkrystian

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:

  • declares neither an explicit specialization nor an explicit instantiation, and
  • does not match the two explicitly permitted forms since it contains a nested-name-specifier.

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 [...]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions