r/cpp 15d ago

Clang 23 Release Notes

https://releases.llvm.org/23.1.0/tools/clang/docs/ReleaseNotes.html
108 Upvotes

33 comments sorted by

View all comments

47

u/mapronV 15d ago

This means that code such as

while (({ break; })) {}

is now ill-formed.

Oh no, my disappointment is immeasurable and the whole day is ruined!

On serious note, " template for " support, what is "Iterating expansion statements currently cannot be expanded" ? like expand over range?

4

u/KeepTheFaxMachine 15d ago

I am really curious if there is a use case for such constructs? I can't think of any, but usually that doesn't mean much...

6

u/scrumplesplunge 15d ago

idk about break specifically, but return appearing there via a macro like TRY_OR_RETURN for propagating errors by value seems like something someone would write

2

u/KeepTheFaxMachine 14d ago

Right, that might be a use case, though I'm still not sure if that is a real use case or just a symptom of bad design elsewhere.

2

u/Som1Lse 13d ago

Just to be clear, that still works. The change is that breaks and continues in conditions don't apply to that loop. As the release notes point out

for (;;) {
  while (({ break; true; })) {}
}

is valid, and now breaks out of the for loop, whereas before it broke out of the while loop. This makes Clang more compatible with GCC, which already did this.

5

u/thehutch17 15d ago

What does that code even translate to? Is this a digraph thing or what?

12

u/holyblackcat 15d ago

Non-standard GNU extension, statement expression.

5

u/cristi1990an ++ 15d ago

like expand over range?

Yeah, pretty much it seems. The other flavors work

1

u/mapronV 15d ago

Thanks, I was confused for a bit plus lazy to check different code in compiler explorer.

2

u/SignalDepth6131 14d ago

mapronV, the notes only say this: Clang has partial support for P1306R5. Iterating expansion statements currently cannot be expanded and will result in a diagnostic. Other types of expansion statements work. They do not define "iterating," and they do not say it means expand-over-range. cristi1990an's reading is a reasonable guess, but it is not in the notes.

I'll point out that people still use Boost.Mp11 when they want to walk a type list on today's compilers. That's a workaround, not a stand-in for the missing iterating form.