public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/48968] incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64)
2011-05-11 20:04 [Bug c/48968] New: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64) eggert at gnu dot org
@ 2011-05-11 20:00 ` eggert at gnu dot org
2011-05-12 11:07 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: eggert at gnu dot org @ 2011-05-11 20:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48968
--- Comment #1 from eggert at gnu dot org 2011-05-11 19:35:32 UTC ---
Created attachment 24227
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24227
gzip-compressed u.i program, illustrating incorrect diagnostic
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/48968] New: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64)
@ 2011-05-11 20:04 eggert at gnu dot org
2011-05-11 20:00 ` [Bug c/48968] " eggert at gnu dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: eggert at gnu dot org @ 2011-05-11 20:04 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/48968] incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64)
2011-05-11 20:04 [Bug c/48968] New: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64) eggert at gnu dot org
2011-05-11 20:00 ` [Bug c/48968] " eggert at gnu dot org
@ 2011-05-12 11:07 ` rguenth at gcc dot gnu.org
2011-05-12 13:54 ` schwab@linux-m68k.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-05-12 11:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48968
--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-12 09:11:45 UTC ---
Well, XXXevent is scalarized by SRA (-fno-tree-sra gets rid of the error) and
I suppose nothing prevents that register to be propagated to other indirect
uses. So it might be indeed live over the setjmp call.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/48968] incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64)
2011-05-11 20:04 [Bug c/48968] New: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64) eggert at gnu dot org
2011-05-11 20:00 ` [Bug c/48968] " eggert at gnu dot org
2011-05-12 11:07 ` rguenth at gcc dot gnu.org
@ 2011-05-12 13:54 ` schwab@linux-m68k.org
2011-05-12 19:11 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: schwab@linux-m68k.org @ 2011-05-12 13:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48968
--- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> 2011-05-12 11:00:16 UTC ---
That function doesn't actually call setjmp.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/48968] incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64)
2011-05-11 20:04 [Bug c/48968] New: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64) eggert at gnu dot org
` (2 preceding siblings ...)
2011-05-12 13:54 ` schwab@linux-m68k.org
@ 2011-05-12 19:11 ` jakub at gcc dot gnu.org
2011-05-12 20:22 ` eggert at gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-12 19:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48968
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-12 18:55:39 UTC ---
read_char calls setjmp.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/48968] incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64)
2011-05-11 20:04 [Bug c/48968] New: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64) eggert at gnu dot org
` (3 preceding siblings ...)
2011-05-12 19:11 ` jakub at gcc dot gnu.org
@ 2011-05-12 20:22 ` eggert at gnu dot org
2012-06-01 20:42 ` eggert at gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: eggert at gnu dot org @ 2011-05-12 20:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48968
--- Comment #5 from eggert at gnu dot org 2011-05-12 19:52:20 UTC ---
A register may be live (after inlining), but the local variable XXXevent is not
live across the setjmp call, so surely the warning is wrong even if the
generated code is correct.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/48968] incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64)
2011-05-11 20:04 [Bug c/48968] New: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64) eggert at gnu dot org
` (4 preceding siblings ...)
2011-05-12 20:22 ` eggert at gnu dot org
@ 2012-06-01 20:42 ` eggert at gnu dot org
2012-06-01 21:19 ` eggert at gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: eggert at gnu dot org @ 2012-06-01 20:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48968
eggert at gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|4.6.0 |4.7.0
--- Comment #6 from eggert at gnu dot org 2012-06-01 20:42:42 UTC ---
I just now ran into the bug again when compiling a new Emacs version and so am
following up.
The function read_char_minibuf_menu_prompt does not call setjmp. Apparently
GCC is inlining the function into some other place and then complaining that
the result is unsafe, but this sort of inlining would be incorrect if it
actually made the code unsafe, so the diagnostic is either incorrect, or (if
correct) indicates the possibility that the wrong code has been generated. I
have verified that the problem is still there with GCC 4.7.0 and so I'll try to
change the version number in this bug report.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/48968] incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64)
2011-05-11 20:04 [Bug c/48968] New: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64) eggert at gnu dot org
` (5 preceding siblings ...)
2012-06-01 20:42 ` eggert at gnu dot org
@ 2012-06-01 21:19 ` eggert at gnu dot org
2014-01-19 18:01 ` mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: eggert at gnu dot org @ 2012-06-01 21:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48968
--- Comment #7 from eggert at gnu dot org 2012-06-01 21:19:16 UTC ---
Created attachment 27546
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27546
alternate test case, for x86, showing "({anonymous}) might be clobbered"
By compiling on x86 (as opposed to x86-64) and tweaking the source code a bit I
got a different diagnostic "error: variable '({anonymous})' might be clobbered
by 'longjmp' or 'vfork'" which may help indicate where the problem is.
Uncompress and compile the attached program with:
gcc -v -m32 -std=gnu99 -c -Werror=clobbered -g -O2 t.i
and the output is:
Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.7.0/configure
--prefix=/home/eggert/opt/Linux-x86_64/gcc-4.7.0 --disable-nls
Thread model: posix
gcc version 4.7.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-m32' '-std=gnu99' '-c' '-Werror=clobbered' '-g'
'-O2' '-mtune=generic' '-march=x86-64'
/home/eggert/opt/Linux-x86_64/gcc-4.7.0/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/cc1
-fpreprocessed t.i -quiet -dumpbase t.i -m32 -mtune=generic -march=x86-64
-auxbase t -g -O2 -Werror=clobbered -std=gnu99 -version -o /tmp/cc9OhgtR.s
GNU C (GCC) version 4.7.0 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.7.0, GMP version 4.3.2, MPFR version 3.0.0, MPC
version 0.8.3-dev
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C (GCC) version 4.7.0 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.7.0, GMP version 4.3.2, MPFR version 3.0.0, MPC
version 0.8.3-dev
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 0b542ccc033bf565e8473ef2771f60ec
t.i: In function 'read_char':
t.i:14930:1: error: variable '({anonymous})' might be clobbered by 'longjmp' or
'vfork' [-Werror=clobbered]
t.i:14930:1: error: variable '({anonymous})' might be clobbered by 'longjmp' or
'vfork' [-Werror=clobbered]
t.i:14930:1: error: variable '({anonymous})' might be clobbered by 'longjmp' or
'vfork' [-Werror=clobbered]
t.i:14930:1: error: variable '({anonymous})' might be clobbered by 'longjmp' or
'vfork' [-Werror=clobbered]
cc1: some warnings being treated as errors
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/48968] incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64)
2011-05-11 20:04 [Bug c/48968] New: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64) eggert at gnu dot org
` (6 preceding siblings ...)
2012-06-01 21:19 ` eggert at gnu dot org
@ 2014-01-19 18:01 ` mpolacek at gcc dot gnu.org
2014-01-19 18:34 ` eggert at gnu dot org
2014-01-19 20:31 ` mpolacek at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-19 18:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48968
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |mpolacek at gcc dot gnu.org
Resolution|--- |FIXED
--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Can't reproduce anymore with 4.7/4.8/4.9 (but with 4.6 I can), thus hopefully
fixed.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/48968] incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64)
2011-05-11 20:04 [Bug c/48968] New: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64) eggert at gnu dot org
` (7 preceding siblings ...)
2014-01-19 18:01 ` mpolacek at gcc dot gnu.org
@ 2014-01-19 18:34 ` eggert at gnu dot org
2014-01-19 20:31 ` mpolacek at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: eggert at gnu dot org @ 2014-01-19 18:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48968
eggert at gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|FIXED |---
--- Comment #9 from eggert at gnu dot org ---
(In reply to Marek Polacek from comment #8)
> Can't reproduce anymore with 4.7/4.8/4.9 (but with 4.6 I can), thus
> hopefully fixed.
Thanks, but which test case did you use, and which version of 4.8? I can
reproduce the bug with the first test case (u.i) with the GCC 4.8.2 that is
shipped with Fedora 20 (it says it is "gcc (GCC) 4.8.2 20131212 (Red Hat
4.8.2-7)"). That is, the bug with the second test case is fixed with 4.8.2,
but the bug with the first test case remains.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/48968] incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64)
2011-05-11 20:04 [Bug c/48968] New: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64) eggert at gnu dot org
` (8 preceding siblings ...)
2014-01-19 18:34 ` eggert at gnu dot org
@ 2014-01-19 20:31 ` mpolacek at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-19 20:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48968
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-01-19
Ever confirmed|0 |1
--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Ah, on u.i I can see it, too. Sorry, I thought the testcases are equivalent.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-01-19 20:31 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-11 20:04 [Bug c/48968] New: incorrect warning about longjmp/vfork clobbering a local (-W -O2, x86-64) eggert at gnu dot org
2011-05-11 20:00 ` [Bug c/48968] " eggert at gnu dot org
2011-05-12 11:07 ` rguenth at gcc dot gnu.org
2011-05-12 13:54 ` schwab@linux-m68k.org
2011-05-12 19:11 ` jakub at gcc dot gnu.org
2011-05-12 20:22 ` eggert at gnu dot org
2012-06-01 20:42 ` eggert at gnu dot org
2012-06-01 21:19 ` eggert at gnu dot org
2014-01-19 18:01 ` mpolacek at gcc dot gnu.org
2014-01-19 18:34 ` eggert at gnu dot org
2014-01-19 20:31 ` mpolacek at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).