-
Notifications
You must be signed in to change notification settings - Fork 7
Description
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.