This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/21161] [6/7/8 Regression] "clobbered by longjmp" warning ignores the data flow
- From: "bergner at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 04 Mar 2018 16:29:51 +0000
- Subject: [Bug middle-end/21161] [6/7/8 Regression] "clobbered by longjmp" warning ignores the data flow
- Auto-submitted: auto-generated
- References: <bug-21161-4@http.gcc.gnu.org/bugzilla/>
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)
~~^~~