C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Bringing break/continue with label to C++

From: Jan Schultke <janschultke_at_[hidden]>
Date: Thu, 19 Dec 2024 09:36:26 +0100
> But now you can't not define a label where you can use goto, but also all labels must be associable to statements that follow it.

No? You can still write:
> goto end;
> {
> end:
> }

No statement is following end:, and this is valid C23 to my knowledge.

Literally nothing changes about code that already uses labels and
gotos. No code is broken or has its semantics changed; neither with
N3355, nor with my proposal for C++.

> Not to mention that this comes with all the restrictions of existing labels, such as the name being unique everywhere in the function instead of creating a temporary spot.

My proposal lifts those restrictions so that you can use duplicate
labels. See https://eisenwave.github.io/cpp-proposals/break-continue-label.html#changes-to-labels
I believe this to be a much less invasive change than inventing new
syntax for loops, and I will propose similar changes to C.

Received on 2024-12-19 08:36:38