This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


956. Function prototype scope with late-specified return types

Section: 9.3.4.6  [dcl.fct]     Status: CD2     Submitter: Daveed Vandevoorde     Date: 21 August, 2009

[Voted into WP at March, 2010 meeting.]

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]

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]