Skip to content

CWG2717 [temp.variadic] should specify a special case for the expansion of alignment-specifier  #296

Closed
cplusplus/draft
#6328
@xmh0511

Description

@xmh0511

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

[dcl.align] p1 says

An alignment-specifier with an ellipsis is a pack expansion ([temp.variadic]).

template<class ...T>
struct Align{
  alignas(T...) unsigned char buffer[128];
};

If there is no special specification, the expansion is defined as [temp.variadic] p8

The instantiation of a pack expansion considers items E1,E2,…,EN, where N is the number of elements in the pack expansion parameters. Each Ei is generated by instantiating the pattern and replacing each pack expansion parameter with its ith element.

[temp.variadic] p11

The instantiation of any other pack expansion produces a list of elements E1,E2,…,EN.

That is, given Align<int, short> will instantiate the pack expansion to produce alignas(int), alignas(short), which is not a valid attribute-specifier-seq in a declaration. That is, a valid attribute-specifier-seq in a declaration is not comma-separated. Even if the note in the [temp.variadic] p11 may imply the intent, however, it's not a formal rule

[Note 1: The variety of list varies with the context: expression-list, base-specifier-list, template-argument-list, etc.
— end note]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions