This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-11-11
[Accepted as a DR at the June, 2023 meeting.]
Iteration statements such as while and for loops are specified by equivalent code involving goto (8.6.2 [stmt.while] paragraph 2, 8.6.4 [stmt.for] paragraph 1, 8.6.5 [stmt.ranged] paragraph 1). The goto statement cannot be evaluated in constant expressions (7.7 [expr.const] bullet 5.30), thus while and for loops cannot be evaluated in constant expressions. Similar concerns arise for continue (8.7.3 [stmt.cont] paragraph 1).
However, that is neither intended nor existing practice.
Suggested resolution [SUPERSEDED]:
Change in 7.7 [expr.const] bullet 5.30 as follows:
An expression E is a core constant expression unless the evaluation of E, following the rules of the abstract machine (6.9.1 [intro.execution]), would evaluate one of the following:
CWG 2023-03-30
Keep the rule non-normative and non-exhaustive.
Proposed resolution (approved by CWG 2023-04-28):
Change in 7.7 [expr.const] bullet 5.30 as follows:
An expression E is a core constant expression unless the evaluation of E, following the rules of the abstract machine (6.9.1 [intro.execution]), would evaluate one of the following:
- ...
- a goto statement (8.7.6 [stmt.goto]). [ Note: A goto statement introduced by equivalence (Clause 8 [stmt.stmt]) is not in scope. For example, a while statement (8.6.2 [stmt.while]) can be executed during constant evaluation. -- end note ].