Skip to content

CWG2476 [dcl.spec.auto.general] p3 "function declarator" in the rule has a ambiguous meaning #85

@xmh0511

Description

@xmh0511

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

A stackoverflow question: Is a pointer to function (sometimes/always?) a function declarator?

[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. Otherwise, the function declarator shall declare a function.

Does the function declarator refer to the declarator in a declaration that first matches the form defined in [dcl.fct](namely, fun in T fun();, or to the declarator that is comprised by a declaration that declares a function(namely, T *fun();)? In the latter declaration, the declarator first matches the form defined in [dcl.ptr].

Presumably, the wording "function declarator" intends to refer to both.

Suggested resolution

Change [dcl.spec.auto.general] p3 to

A placeholder type can appear with a function declarator in the decl-specifier-seq, type-specifier-seq, conversion-function-id, or trailing-return-type, in any context where such a declarator is valid. If the function declarator includes a trailing-return-type ([dcl.fct]), that trailing-return-type specifies the declared return type of the function. If the declared return type of the function contains a placeholder type, either the minimum constituent declaration in which the function declarator appears shall be one of the following:

  • is a paramter-declaration, or
  • is a initializing declaration of a variable, or
  • declares a function.

or the function declarator shall appear in the type-id of a new-expression.

The proposed resolution tries to make the intent of the "function declarator" clear and fix the remaining issue in CWG2476.

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