zygoloid wrote:

It looks like GCC changed their behavior in version 9 onwards. In [prior 
versions](https://godbolt.org/z/85dvbe1rG), a `continue` in the condition or 
increment of a `for` loop would branch to the continue block of that `for` 
loop. But, only in C++ (in C it branches to the continue block of the outer 
loop), and only if there *is* an outer loop (otherwise it gets rejected early).

Prior to C++11, various major libraries (including both boost and Qt, as I 
recall) provided foreach macros that relied on this behavior, so Clang had to 
follow it. And instead of following it only in C++ and only when there's an 
enclosing loop, we chose to behave more consistently and allow it in both C and 
C++, regardless of whether there's an enclosing loop.

It looks like GCC 9 onwards finally converged on the more sensible behavior -- 
that `break` and `continue` in a loop increment / condition are not in the 
scope of that loop. I guess we should follow suit, but this is a breaking 
change for code that old GCC and Clang supported.

https://github.com/llvm/llvm-project/pull/152606
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to