C++ Logo


Advanced search

Substatements of consteval if statements

From: 耕 程 <xmcgcg_at_[hidden]>
Date: Thu, 21 Jul 2022 14:17:14 +0000
N4910 [stmt.pre] paragraph 2 states:
A substatement of a statement is one of the following:

l …

l for a selection-statement, any of its statements (but not its init-statement), or…

Consteval if statements (and consteval if equivalent statements, if ! is present) have the following syntaxes:
if !opt consteval compound-statement
if !opt consteval compound-statement else statement

The syntaxes use compound-statement as the if-block instead of statement, while the semantic implies that compound-statement should be treated as a substatement (N4910 [stmt.if] paragraph 5):
If a consteval if statement is evaluated in a context that is manifestly constant-evaluated, the first substatement is executed.

‘The first substatement’ can only refer to compound-statement.

Does the definition of substatement exclude compound-statement appearing in the syntaxes from being substatements? If so, this is clearly a defect.

Received on 2022-07-21 14:17:17