[Bug c/48968] New: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64)
eggert at gnu dot org
gcc-bugzilla@gcc.gnu.org
Wed May 11 20:04:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48968
Summary: incorrect warning about longjmp/vfork clobbering a
local (-W -O2, x86-64)
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: eggert@gnu.org
The attached program u.i, derived from the Emacs trunk,
has code of the following form:
Lisp_Object XXXevent, tem;
if (idx < 0)
{
XXXevent = Qnil;
}
else
{
Lisp_Object _l; _l.s.val = idx; _l.s.type = Lisp_Int;
XXXevent = _l;
}
if ((((enum Lisp_Type) ((XXXevent)).u.type)) == Lisp_Int)
{
...
}
These are the only defs and uses of XXXevent, which is a local
variable of union type. When compiled with -W -O2 on x86-64,
GCC 4.6.0 complains:
error: variable 'XXXevent' might be clobbered by 'longjmp' or 'vfork'
But no longjmp or vfork is possible between the time that XXXevent is
set, and the time that it is used.
I worry that this bogus warning is a symptom of deeper problems in
GCC 4.6.0's optimizer.
Here is the full output of:
gcc -v -save-temps -S -W -Wno-missing-field-initializers -Wno-sign-compare
-Werror -O2 u.i
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local_cs/linux/gcc-4.6.0/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.6.0/configure --prefix=/usr/local/cs/gcc-4.6.0
--with-gmp-include=/usr/local/cs/include --disable-nls
--with-stage1-ldflags='-L/usr/local/cs/lib64 -Xlinker
-rpath=/usr/local/cs/lib64' --with-boot-ldflags='-L/usr/local/cs/lib64 -Xlinker
-rpath=/usr/local/cs/lib64' LDFLAGS='-L/usr/local/cs/lib64 -Xlinker
-rpath=/usr/local/cs/lib64'
Thread model: posix
gcc version 4.6.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-S' '-Wextra'
'-Wno-missing-field-initializers' '-Wno-sign-compare' '-Werror' '-O2'
'-mtune=generic' '-march=x86-64'
/usr/local_cs/linux/gcc-4.6.0/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/cc1
-fpreprocessed u.i -quiet -dumpbase u.i -mtune=generic -march=x86-64 -auxbase u
-O2 -Wextra -Wno-missing-field-initializers -Wno-sign-compare -Werror -version
-o u.s
GNU C (GCC) version 4.6.0 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.6.0, GMP version 5.0.2, MPFR version
3.0.1-p4, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C (GCC) version 4.6.0 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.6.0, GMP version 5.0.2, MPFR version
3.0.1-p4, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 48a4f3d76c3a714a5f5622b4f42440c5
u.i: In function 'read_char':
u.i:60167:20: error: variable 'XXXevent' might be clobbered by 'longjmp' or
'vfork' [-Werror=clobbered]
cc1: all warnings being treated as errors
More information about the Gcc-bugs
mailing list