Skip to content

CWG2476 [dcl.spec.auto.general] p2 Is the type of "auto(*)(int)->auto" a generic parameter type placeholder #84

@xmh0511

Description

@xmh0511

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

[dcl.spec.auto.general] p2 says

if it is not the auto type-specifier introducing a trailing-return-type (see below), is a generic parameter type placeholder of the function declaration or lambda-expression.

Consider this example

void fun(auto(*)(int)->auto){

}

The auto type-specifier does introduce a trailing-return-type, so the specified type is not a generic parameter type placeholder?

Divergence: Clang accepts this example but GCC rejects it.

It seems to make sense that Clang accepts the example since [dcl.spec.auto.general] p3 says

If the function declarator includes a trailing-return-type ([dcl.fct]), that trailing-return-type specifies the declared return type of the function.

This declaration behaves as if it were auto(*)(int).

Suggested resolution

if it is either

  • not the auto type-specifier introducing a trailing-return-type(see below), or
  • the auto type-specifier introducing the trailing-return-type containing a placeholder type

is a generic parameter type placeholder of the function declaration or lambda-expression.

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