[Bug c++/118726] GCC generates wrong code when using non-structured binding declaration as the condition of a for-loop at O2 level
xiaohuba2021 at 163 dot com
gcc-bugzilla@gcc.gnu.org
Sun Feb 2 06:15:11 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118726
--- Comment #2 from xiaohuba2021 <xiaohuba2021 at 163 dot com> ---
There is a typo in the code mentioned above. The correct version is:
```
#include <iostream>
int main() {
volatile int x = 10;
for (int l = 1; int d = x - l; l = d + 1) {
int &z = d;
std::cout << z << '\n';
}
}
```
More information about the Gcc-bugs
mailing list