https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100049
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Christophe Lyon from comment #4) > Actually 'man longjmp' says: > > The compiler may optimize variables into registers, and longjmp() > may > restore the values of other registers in addition to the stack > pointer > and program counter. Consequently, the values of automatic > variables > are unspecified after a call to longjmp() if they meet all the > follow‐ > ing criteria: > > • they are local to the function that made the corresponding > setjmp() > call; > > • their values are changed between the calls to setjmp() > and > longjmp(); and > > • they are not declared as volatile. > > In this case, "i" is not modified between setjmp() and longjmp(), but it > seems the compiler moves the increment between them. Except the compiler does NOT know in this case if the setjmp and longjmp are matching so i could be modified.