This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/21161] [6/7/8 Regression] "clobbered by longjmp" warning ignores the data flow


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21161

--- Comment #14 from Peter Bergner <bergner at gcc dot gnu.org> ---
(In reply to Peter Bergner from comment #13)
> In case you haven't creduce'd the test case yet, here's what I got:

Of course that's a totally bogus test case given what Bruno was trying to
prove, namely that obj is never updated between the setjmp call and the call to
longjmp, therefor we shouldn't get a warning.  I think the following test case
does show what Bruno was trying to prove.

bergner@pike:~/gcc/BUGS/PR21161$ cat bug.c 
#include <setjmp.h>

typedef struct { long a; } * b;
b global_obj;

void
c (b obj)
{
  jmp_buf env;
  if (setjmp(env) != 0)
    obj = global_obj;
  if (obj->a)
    longjmp (env, 1);
}
bergner@pike:~/gcc/BUGS/PR21161$
/home/bergner/gcc/build/gcc-fsf-mainline-debug/gcc/xgcc
-B/home/bergner/gcc/build/gcc-fsf-mainline-debug/gcc -W -O1 -S bug.c 
bug.c: In function ‘c’:
bug.c:7:6: warning: argument ‘obj’ might be clobbered by ‘longjmp’ or ‘vfork’
[-Wclobbered]
 c (b obj)
    ~~^~~

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]