[basic.scope.block] (original) (raw)

A name declared in a block ([stmt.block]) is local to that block; it hasblock scope.

Its potential scope begins at its point of declaration ([basic.scope.pdecl]) and ends at the end of its block.

A variable declared at block scope is a local variable.

Names declared in the init-statement, the for-range-declaration, and in thecondition of if, while, for, andswitch statements are local to the if, while,for, or switch statement (including the controlled statement), and shall not be redeclared in a subsequent condition of that statement nor in the outermost block (or, for the ifstatement, any of the outermost blocks) of the controlled statement.

[ Example

:

if (int x = f()) { int x; // error: redeclaration of x } else { int x; // error: redeclaration of x }

end example

]