Date: Thu, 8 Dec 2022 17:24:37 +0500
> According to the C++ 20 Standard (Reference: 6.4.4 Function parameter scope)
> «1 A function parameter (including one appearing in a lambda-declarator) or function-local predefined variable (9.5) has function parameter scope….»
The next sentence: «The potential scope of a parameter or function-local predefined variable begins at its point of declaration»
[basic.scope.pdecl]/9: «The point of declaration for a function-local predefined variable is immediately before the function-body of a function definition.»
> So should this function declaration be valid?
>
> void f( size_t n = sizeof __func__ );
No.
> Pay attention to that there is used a function declaration that is not the function definition.
There is no point of declaration of __func__ here, then.
> «1 A function parameter (including one appearing in a lambda-declarator) or function-local predefined variable (9.5) has function parameter scope….»
The next sentence: «The potential scope of a parameter or function-local predefined variable begins at its point of declaration»
[basic.scope.pdecl]/9: «The point of declaration for a function-local predefined variable is immediately before the function-body of a function definition.»
> So should this function declaration be valid?
>
> void f( size_t n = sizeof __func__ );
No.
> Pay attention to that there is used a function declaration that is not the function definition.
There is no point of declaration of __func__ here, then.
Received on 2022-12-08 12:24:42