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 10:27:02 +0100
> From a compiler perspective, it could have to produce slightly different code, when encountering `goto label` vs. `break label` or `continue label`.

Hmm yeah. I think an argument can be made here that "label:" could
have translated quite literally to a label in assembly with the same
name. "break label" requires auto-generating a new label past the end
of the broken loop, just like a regular "break". Not really an issue,
but some interesting observations.

> The myfor label is outside of the for loop, but continue myfor does not destroy o and constructing a new one, but stays inside the loop.

The exact same thing happens when that for loop is targeted by a plain
"continue" without no label. "continue;" and "continue l;' should
behave exactly the same, as long as they refer to the same loop. This
is the behavior in any other language with "continue label;" as well,
and the currently proposed behavior of N3355, N3377, and my proposal.

There is nothing to be fixed here.

I do agree that it's not all that nice that "continue;" jumps to the
end of the loop (but still inside the loop) in general, but that's
just how it's always been at this point.

> We probably need the following ;-)

(^▽^) good one.

Received on 2024-12-19 09:27:19