Slides for P3568R1
break label; and continue label;
- Document number:
- P3722R0
- Date:
2025-05-27 - Audience:
- SG22
- Project:
- ISO/IEC 14882 Programming Languages — C++, ISO/IEC JTC1/SC22/WG21
- Reply-To:
- Jan Schultke <janschultke@gmail.com>
- Source:
- github.com/Eisenwave/cpp-proposals/blob/master/src/break-continue-label-slides.cow
- →, ↓ : go to the next slide
- ←, ↑ : go to previous slide
break label ;
and
continue label ;
P3568R1
Introduction
C2y now supports
and
with a label (N3355):
- would be useful in C++, not just in C
- if C has it, EWG wants it
- clearly implementable, even in
constexpr
Recent history
Hagenberg 2025
EWG likes syntaxN3355 : for ( ... ) { }
SF | F | N | A | SA |
---|---|---|---|---|
4 | 16 | 5 | 9 | 5 |
for N3377 ( ... ) { }
SF | F | N | A | SA |
---|---|---|---|---|
7 | 13 | 5 | 5 | 8 |
SF | F | N | A | SA |
---|---|---|---|---|
16 | 21 | 5 | 2 | 3 |
Conclusion
Let WG14 figure out syntax;we'll copy the feature into C++.
Recent history
Graz 2025
Would WG14 like to see a paper changingloop name syntax at a future meeting?
F | N | A |
---|---|---|
6 | 11 | 9 |
-
Conclusion:
syntax winsN3355 : for ( ... ) { } - however, major N3377 concerns unaddressed
-
C++ goes with N3355 syntax
- also let's try to fix N3377 issues before WG14
Unaddressed N3377 concerns
Labels must be unique per function ⇒ problematic for macros:
Also, nested reuse of names impossible:
P3568R1 strategy
- labels can go anywhere, even multiple times
- restrict
,goto
,break
, not labelscontinue
- Idea: labels are basically comments, so why restrict them?
- Benefit: very simple, teachable system
Summary
- EWG wants
, and we have a designbreak label - syntax debate is resolved
- N3377 concerns can be addressed with
syntaxlabel : - wording exists, CWG chair looked at it
-
implementation non-trivial, but clearly possible
- GCC patch for N3355 exists (C fronted)
- Clang implementers convinced that
is feasiblebreak label