I have a function like this:
#include
jmp_buf buf;
void func2(int g);
extern int some_global;
void func(int x)
{
if (setjmp(buf))
From man longjmp:
The values of automatic variables are unspecified after a call to longjmp() if they meet all the following criteria:
· they are local to the function that made the corresponding setjmp(3)
call;
· their values are changed between the calls to setjmp(3) and
longjmp(); and
· they are not declared as volatile.
As it happens, your x variable in the first example meets the criteria:
setjmp if some_global is true.So its value may be unspecified (clobbered).
About why the second version does not emit the warning... no idea.