https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100049
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The testcase would be #include <stdio.h> #include <setjmp.h> struct ctx { int cnt; struct S { jmp_buf env; } jmp_buf[4]; } ctx; __attribute__((noipa)) void do_jump (void) { --ctx.cnt; longjmp (ctx.jmp_buf[ctx.cnt].env, 1); } static void test (void) { for (unsigned i = 0; i < 19; i++) { printf ("Message %d\n", i); if (setjmp ((&ctx.jmp_buf[ctx.cnt])->env) == 0) { ++ctx.cnt; do_jump (); --ctx.cnt; } } } int main () { test (); return 0; } And gcc clearly warns about that with -O2 -W -Wall: pr100049.c: In function ‘test’: pr100049.c:16:17: warning: variable ‘i’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Wclobbered] 16 | for (unsigned i = 0; i < 19; i++) | ^