https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100049
--- Comment #4 from Christophe Lyon <clyon at gcc dot gnu.org> --- 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.