C++ Logo


Advanced search

Re: The scope of the function-local predefined variable.

From: Andrew Schepler <aschepler_at_[hidden]>
Date: Mon, 12 Dec 2022 09:41:26 -0500
On Mon, Dec 12, 2022 at 5:02 AM Vladimir Grigoriev <vlad.moscow_at_[hidden]>

> However there is also written in the C++ 2- Standard ( 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 potential scope of a parameter or function-local predefined variable
> begins at its point of declaration. If the nearest enclosing function
> declarator is not the declarator of a function definition, the potential
> scope ends at the end of that function declarator.»
> So how does the example of the function declaration contradict to this
> quote?

I don't see any contradiction. Each of your examples has one function
parameter, and its scope ends after the final semicolon which ends the
declaration. The paragraph applies to all function parameters and
function-local predefined variables which exist in the program as described
elsewhere, but it does not itself say or imply any such parameters or
variables do exist.


Received on 2022-12-12 14:41:39