https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111211
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |inline-asm Summary|No warning for iterator |No warning for iterator |going out of scope |going out of scope for | |writing to array of | |inline-asm --- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Note this is only an issue with inline-asm really and only if write directly in the array. If we change the code slightly: ``` #include <stdint.h> int foo2 (uint64_t ddr0_addr_access) { uint64_t check[1] = {0}; for (int k = 0; k < 8; k += 1) { int t; asm volatile ("nop" : "=r"(t) : "r"(ddr0_addr_access)); check[k] = t; } return 0; } ``` GCC does warn (though slightly different): ``` <source>:11:18: warning: iteration 1 invokes undefined behavior [-Waggressive-loop-optimizations] 11 | check[k] = t; | ~~~~~~~~~^~~ <source>:7:23: note: within this loop 7 | for (int k = 0; k < 8; k += 1) | ~~^~~ ```