Date: Tue, 17 Nov 2026 08:31:45 -0500
On Tue, Nov 17, 2026 at 8:16 AM Ivan Lazaric via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> > The main downside of `goto` is that it can't be used during constant
> evaluation, but I don't think this is a strong enough reason to add new
> keywords to the core language.
>
> I hope one day we allow goto in constexpr. Not really aware of proposals
> pursuing this, relevant stuff:
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4472.html
> https://cplusplus.github.io/EWG/ewg-closed.html#186
>
Constexpr functions have permitted the presence of *non-executed* `goto`
statements since C++23:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2242r3.html
*Executed* `goto` statements are mentioned here:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2026/p3568r3.html#alternative-goto
> Previous discussion on the [isocpp-core] reflector has addressed the idea
> of just adding constexpr goto, but doing so is alleged to be more
> complicated than more limited constexpr control flow structures which can
> only "jump forwards", such as break and continue.
It links to a reflector discussion where [anonymized] says, in part:
`goto` is more significantly more challenging to support in a constant
> evaluator that recursively walks a compiler's AST (rather than using some
> separate control-flow-oriented representation) than `break`, `continue`, or
> `case`.
> For `break` and `continue`, we trivially know both (a) that we're exiting
> some number of scopes, and (b) where to stop exiting scopes -- we can just
> return from the statement evaluation loop when we see a break or continue,
> until we reach a context that knows how to handle it. `case` is much
> harder: we need to enter some number of scopes, including starting the
> lifetimes of variables with vacuous initialization that we encounter along
> the way. Clang handles this by evaluating the `switch` body in a special
> mode that linearly walks the body of the `switch`, entering both arms of an
> `if`, starting the lifetime of every variable encountered along the way,
> and ending the lifetimes of variables when we leave their scope, but
> otherwise not executing any code, until it sees the matching `case` or
> `default` label, where it resumes "normal" execution. That's already, well,
> awful.
> `goto` introduces two additional challenges beyond those of
> `break`/`continue`/`case`:
> (1) It needs to exit some unknown number of evaluation scopes.
> (2) It might need to step some distance backwards within a scope.
> Both of those are hard to address in an evaluator that's performing a
> recursive AST walk. Not completely impossible, I think, but hard [...]
HTH,
–Arthur
On Mon, 16 Nov 2026, 22:12 Vinnie Falco via Std-Proposals, <
>>> std-proposals_at_[hidden]> wrote:
>>>
>>>> On Mon, Nov 16, 2026 at 8:41 AM scbd Gm via Std-Proposals <
>>>> std-proposals_at_[hidden]> wrote:
>>>>
>>>>> I'm interested in proposing a new C++ control-flow statement called
>>>>> repeat.
>>>>>
>>>> What?
>>>>
>>>
"I SAID, I'M INTERESTED IN PROPOSING A NEW C++ CONTROL-FLOW STATEMENT
CALLED REPEAT!"
(But no, it's obviously a bad idea, and doesn't need all this digital ink
spilled over it.)
std-proposals_at_[hidden]> wrote:
> > The main downside of `goto` is that it can't be used during constant
> evaluation, but I don't think this is a strong enough reason to add new
> keywords to the core language.
>
> I hope one day we allow goto in constexpr. Not really aware of proposals
> pursuing this, relevant stuff:
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4472.html
> https://cplusplus.github.io/EWG/ewg-closed.html#186
>
Constexpr functions have permitted the presence of *non-executed* `goto`
statements since C++23:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2242r3.html
*Executed* `goto` statements are mentioned here:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2026/p3568r3.html#alternative-goto
> Previous discussion on the [isocpp-core] reflector has addressed the idea
> of just adding constexpr goto, but doing so is alleged to be more
> complicated than more limited constexpr control flow structures which can
> only "jump forwards", such as break and continue.
It links to a reflector discussion where [anonymized] says, in part:
`goto` is more significantly more challenging to support in a constant
> evaluator that recursively walks a compiler's AST (rather than using some
> separate control-flow-oriented representation) than `break`, `continue`, or
> `case`.
> For `break` and `continue`, we trivially know both (a) that we're exiting
> some number of scopes, and (b) where to stop exiting scopes -- we can just
> return from the statement evaluation loop when we see a break or continue,
> until we reach a context that knows how to handle it. `case` is much
> harder: we need to enter some number of scopes, including starting the
> lifetimes of variables with vacuous initialization that we encounter along
> the way. Clang handles this by evaluating the `switch` body in a special
> mode that linearly walks the body of the `switch`, entering both arms of an
> `if`, starting the lifetime of every variable encountered along the way,
> and ending the lifetimes of variables when we leave their scope, but
> otherwise not executing any code, until it sees the matching `case` or
> `default` label, where it resumes "normal" execution. That's already, well,
> awful.
> `goto` introduces two additional challenges beyond those of
> `break`/`continue`/`case`:
> (1) It needs to exit some unknown number of evaluation scopes.
> (2) It might need to step some distance backwards within a scope.
> Both of those are hard to address in an evaluator that's performing a
> recursive AST walk. Not completely impossible, I think, but hard [...]
HTH,
–Arthur
On Mon, 16 Nov 2026, 22:12 Vinnie Falco via Std-Proposals, <
>>> std-proposals_at_[hidden]> wrote:
>>>
>>>> On Mon, Nov 16, 2026 at 8:41 AM scbd Gm via Std-Proposals <
>>>> std-proposals_at_[hidden]> wrote:
>>>>
>>>>> I'm interested in proposing a new C++ control-flow statement called
>>>>> repeat.
>>>>>
>>>> What?
>>>>
>>>
"I SAID, I'M INTERESTED IN PROPOSING A NEW C++ CONTROL-FLOW STATEMENT
CALLED REPEAT!"
(But no, it's obviously a bad idea, and doesn't need all this digital ink
spilled over it.)
Received on 2026-11-17 13:31:59
