Slides for P3568R2
break label; and continue label;
- Document number:
- P3722R1
- Date:
2026-06-08 - Audience:
- SG22
- Project:
- ISO/IEC 14882 Programming Languages — C++, ISO/IEC JTC1/SC22/WG21
- Reply-To:
- Jan Schultke <janschultke@gmail.com>
- Source:
- break-continue-label-slides.cow
- →, ↓ : go to the next slide
- ←, ↑ : go to previous slide
break label ;
and
continue label ;
P3568R2
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
C++26 Expansion Statements
Breaking out of loop from expanded statement:
Possible future direction: expand labels:
Recent history — Hagenberg 2025
EWG likes syntax
EWG likes syntax
If C has it, we are interested in this feature too.
we'll copy the feature into C++.
N3355 : 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++.
N3658: Simplified lexical scope for labels
Labels must be unique per function ⇒ problematic for macros and nesting:
N3658 solution: drop label restrictions, error on
Recent history — WG14
Graz 2025
Would WG14 like to see a paper changing loop name syntax at a future meeting?| F | N | A |
|---|---|---|
| 6 | 11 | 9 |
Brno 2025
Would WG14 like to adopt something along the lines of N3658 into C2y?| F | N | A |
|---|---|---|
| 18 | 7 | 1 |
P3568R2 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 in WG14 is resolved
- ✅ label problems are resolved (both in WG14 and in P3568R2)
- ✅ wording exists, CWG chair looked at it
-
implementation non-trivial, but possible
- GCC and Clang implement N3355 in C mode
- implemented in
in Clang withconstexpr -Xclang -fnamed-loops - https://godbolt.org/z/faranexn9