Date: Mon, 27 Jan 2025 01:30:48 +1100
On 27/1/25 01:18, Jens Maurer wrote:
>
>
> On 26/01/2025 15.11, Russell Shaw via Std-Discussion wrote:
>> On 27/1/25 00:50, Jens Maurer wrote:
>>>
>>> On 26/01/2025 14.41, Russell Shaw via Std-Discussion wrote:
>>>> The example says:
>>>> auto b = &f<int>; // error: f<int> is an immediate function
>>>>
>>>> But the instantiated function is:
>>>>
>>>> constexpr int f(int t) {
>>>> return t + id(t);
>>>> }
>>>>
>>>> The function parameter scope is '(int t)' (or does it encompass the body too ?)
>>>
>>> It does encompass the function body, otherwise "t" wouldn't be
>>> visible in the body. See [basic.scope.param] p1.
>>>
>>>> Where is the immediate-escalating expression E such that E ’s innermost
>>>> enclosing non-block scope is F ’s function parameter scope ?
>>>
>>> "id(t)" is the expression.
>>
>> Ok.
>> [basic.scope.param] adds no useful information.
>
> How so? It says
>
> "If P is associated with a declarator and is preceded by a (possibly-parenthesized) noptr-declarator of the
> form declarator-id attribute-specifier-seq opt , its scope extends to the end of the nearest enclosing [...]
> function-definition, but [...].
>
> Note the grammar non-terminal "function-definition" there, which covers the
> function body per the grammar in [dcl.fct.def.general].
Hi,
I missed the end of that paragraph that had 'function-definition'.
>> [basic.scope.block] says that the function parameter scope is the parent scope
>> of the function body (if my understanding that the function body is classed as a
>> compound statement and thus a block scope is correct ?)
I retract calling the body a block scope, because declarations in it can clash
with the parameter declarations.
> The function body might be a function-try-block, which is more than
> a compound-statement. See [dcl.fct.def.general].
> Jens
>
>
> On 26/01/2025 15.11, Russell Shaw via Std-Discussion wrote:
>> On 27/1/25 00:50, Jens Maurer wrote:
>>>
>>> On 26/01/2025 14.41, Russell Shaw via Std-Discussion wrote:
>>>> The example says:
>>>> auto b = &f<int>; // error: f<int> is an immediate function
>>>>
>>>> But the instantiated function is:
>>>>
>>>> constexpr int f(int t) {
>>>> return t + id(t);
>>>> }
>>>>
>>>> The function parameter scope is '(int t)' (or does it encompass the body too ?)
>>>
>>> It does encompass the function body, otherwise "t" wouldn't be
>>> visible in the body. See [basic.scope.param] p1.
>>>
>>>> Where is the immediate-escalating expression E such that E ’s innermost
>>>> enclosing non-block scope is F ’s function parameter scope ?
>>>
>>> "id(t)" is the expression.
>>
>> Ok.
>> [basic.scope.param] adds no useful information.
>
> How so? It says
>
> "If P is associated with a declarator and is preceded by a (possibly-parenthesized) noptr-declarator of the
> form declarator-id attribute-specifier-seq opt , its scope extends to the end of the nearest enclosing [...]
> function-definition, but [...].
>
> Note the grammar non-terminal "function-definition" there, which covers the
> function body per the grammar in [dcl.fct.def.general].
Hi,
I missed the end of that paragraph that had 'function-definition'.
>> [basic.scope.block] says that the function parameter scope is the parent scope
>> of the function body (if my understanding that the function body is classed as a
>> compound statement and thus a block scope is correct ?)
I retract calling the body a block scope, because declarations in it can clash
with the parameter declarations.
> The function body might be a function-try-block, which is more than
> a compound-statement. See [dcl.fct.def.general].
> Jens
Received on 2025-01-26 14:30:53