1
votes

[dcl.fct.default]/3 (emphasis is mine):

A default argument shall be specified only in the parameter-declaration-clause of a function declaration or lambda-declarator or in a template-parameter (14.1); in the latter case, the initializer-clause shall be an assignment-expression. A default argument shall not be specified for a parameter pack. If it is specified in a parameter-declaration-clause, it shall not occur within a declarator or abstract-declarator of a parameter-declaration.

The last sentence above says that if a default argument is specified in a parameter-declaration-clause, it shall not occur within a declarator or abstract-declarator, of a parameter-declaration. Nevertheless, when I look at the definition of parameter-declaration, I find the following in [dcl.fct]/3 (emphasis is mine):

parameter-declaration:
    attribute-specifier-seqopt decl-specifier-seq declarator
    attribute-specifier-seqopt decl-specifier-seq declarator = initializer-clause
    attribute-specifier-seqopt decl-specifier-seq abstract-declaratoropt
    attribute-specifier-seqopt decl-specifier-seq abstract-declaratoropt = initializer-clause

1

1 Answers

2
votes

There is a footnote in the Standard

102) This means that default arguments cannot appear, for example, in declarations of pointers to functions, references to functions, or typedef declarations

For example these declarations

void f(void g(int = 10));

void ( *pf )(int = 10);

are wrong.