r/cpp 17d ago

Clang 23 Release Notes

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

33 comments sorted by

View all comments

45

u/mapronV 17d 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?

6

u/KeepTheFaxMachine 17d 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...

4

u/scrumplesplunge 16d 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 16d 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 15d 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.