Title
Function prototype scope with late-specified return types
Status
cd2
Section
9.3.4.6 [dcl.fct]
Submitter
Daveed Vandevoorde

Created on 2009-08-21.00:00:00 last changed 143 months ago

Messages

Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting.]

Date: 2010-02-15.00:00:00

Proposed resolution (February, 2010):

Change the note in 9.3.4.6 [dcl.fct] paragraph 10 as follows:

...[Note: in particular, parameter names are also optional in function definitions and names used for a parameter in different declarations and the definition of a function need not be the same. If a parameter name is present in a function declaration that is not a definition, it cannot be used outside of the parameter-declaration-clause since it goes out of scope at the end of the function declarator (6.4 [basic.scope]) its function declarator because that is the extent of its potential scope (6.4.4 [basic.scope.param]). —end note]
Date: 2020-12-15.00:00:00

According to 6.4.4 [basic.scope.param] paragraph 1,

In a function declaration, or in any function declarator except the declarator of a function definition (9.5 [dcl.fct.def]), names of parameters (if supplied) have function prototype scope, which terminates at the end of the nearest enclosing function declarator.

Happily, this permits the use of parameter names with decltype in a late-specified return type, because the return type is part of the function's declarator. However, the note in 9.3.4.6 [dcl.fct] paragraph 11 is now inaccurate and should be updated:

[Note: ...If a parameter name is present in a function declaration that is not a definition, it cannot be used outside of the parameter-declaration-clause since it goes out of scope at the end of the function declarator (6.4 [basic.scope]). —end note]
History
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2707
2010-03-29 00:00:00adminsetstatus: tentatively ready -> cd2
2010-02-16 00:00:00adminsetmessages: + msg2500
2010-02-16 00:00:00adminsetstatus: drafting -> tentatively ready
2009-11-08 00:00:00adminsetstatus: open -> drafting
2009-08-21 00:00:00admincreate