Skip to content

[basic.scope.block] p1 The note should be as a normative rule #4841

Open
@xmh0511

Description

@xmh0511

Each

  • selection or iteration statement ([stmt.select], [stmt.iter]),
  • substatement of such a statement,
  • handler ([except.pre]), or
  • compound statement ([stmt.block]) that is not the compound-statement of a handler

introduces a block scope that includes that statement or handler.

[Note 1: A substatement that is also a block has only one scope. — end note]

Isn't that note should be phrased as a normative rule? My proposal is that

Each

  • [...]
  • substatement of such a statement that is not a compound-statement,
  • [...]
  • compound statement ([stmt.block]) that is not the compound-statement of a handler

introduces a block scope that includes that statement or handler.

[Note 1: A substatement that is also a block has only one scope. — end note].

if(true) {
}

The substatement is a compound-statement, hence the second bullet does not apply but the last bullet does, which means the substatement only introduced one block scope.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions