public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/52560] New: if (r == -1) causes 'assuming signed overflow does not occur when simplifying conditional to constant'
@ 2012-03-12 11:19 rjones at redhat dot com
2012-03-12 12:30 ` [Bug c/52560] " jim at meyering dot net
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: rjones at redhat dot com @ 2012-03-12 11:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52560
Bug #: 52560
Summary: if (r == -1) causes 'assuming signed overflow does not
occur when simplifying conditional to constant'
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: rjones@redhat.com
Here is the reproducer:
wget 'http://oirase.annexia.org/strict-overflow-warning.i.xz'
unxz strict-overflow-warning.i.xz
gcc -std=gnu99 -O2 -Wstrict-overflow -c strict-overflow-warning.i
The warning is:
inspect_fs_unix.c: In function ‘check_fstab’:
inspect_fs_unix.c:1075:6: warning: assuming signed overflow does not occur
when simplifying conditional to constant [-Wstrict-overflow]
However the code doesn't look like anything should be simplified,
or a warning:
n_app_md_devices = map_app_md_devices (g, &app_map);
if (n_app_md_devices == -1) goto error;
where map_app_md_devices is a function that returns an int:
static int map_app_md_devices (guestfs_h *g, Hash_table **map);
and n_app_md_devices is also an int.
I've tried this on several versions of gcc:
gcc (GCC) 4.7.0 20120308 (Red Hat 4.7.0-0.19)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
(for further build info, go to:
http://koji.fedoraproject.org/koji/buildinfo?buildID=305760
and click 'build logs')
Same thing with this gcc from Ubuntu 11.10:
$ gcc --version
gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
We think this first started happening in gcc 4.5.1.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/52560] if (r == -1) causes 'assuming signed overflow does not occur when simplifying conditional to constant'
2012-03-12 11:19 [Bug c/52560] New: if (r == -1) causes 'assuming signed overflow does not occur when simplifying conditional to constant' rjones at redhat dot com
@ 2012-03-12 12:30 ` jim at meyering dot net
2012-03-12 13:23 ` [Bug tree-optimization/52560] " rguenth at gcc dot gnu.org
2012-03-12 16:31 ` rjones at redhat dot com
2 siblings, 0 replies; 4+ messages in thread
From: jim at meyering dot net @ 2012-03-12 12:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52560
--- Comment #1 from jim at meyering dot net 2012-03-12 12:30:20 UTC ---
Created attachment 26877
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26877
50-line reproducer
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/52560] if (r == -1) causes 'assuming signed overflow does not occur when simplifying conditional to constant'
2012-03-12 11:19 [Bug c/52560] New: if (r == -1) causes 'assuming signed overflow does not occur when simplifying conditional to constant' rjones at redhat dot com
2012-03-12 12:30 ` [Bug c/52560] " jim at meyering dot net
@ 2012-03-12 13:23 ` rguenth at gcc dot gnu.org
2012-03-12 16:31 ` rjones at redhat dot com
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-12 13:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52560
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-03-12
Component|c |tree-optimization
Ever Confirmed|0 |1
--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-12 13:22:32 UTC ---
It certainly inlines the function, does not figures out the loop does not run
and then computes n's value-range as is [0, +INF(OVF)] and thus when
simplifying
the return value comparison against -1 it says it assumes that n++ does not
wrap.
Looks ok to me, though it is all because of dead code and thus a missed
VRP of some sort.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/52560] if (r == -1) causes 'assuming signed overflow does not occur when simplifying conditional to constant'
2012-03-12 11:19 [Bug c/52560] New: if (r == -1) causes 'assuming signed overflow does not occur when simplifying conditional to constant' rjones at redhat dot com
2012-03-12 12:30 ` [Bug c/52560] " jim at meyering dot net
2012-03-12 13:23 ` [Bug tree-optimization/52560] " rguenth at gcc dot gnu.org
@ 2012-03-12 16:31 ` rjones at redhat dot com
2 siblings, 0 replies; 4+ messages in thread
From: rjones at redhat dot com @ 2012-03-12 16:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52560
--- Comment #3 from Richard W.M. Jones <rjones at redhat dot com> 2012-03-12 16:30:45 UTC ---
I see that this is actually a bug in our code. I pushed
the following fix to libguestfs:
https://github.com/libguestfs/libguestfs/commit/d66dd2260c724bdfe57a8595aac37c8e9173cee5
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-03-12 16:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-12 11:19 [Bug c/52560] New: if (r == -1) causes 'assuming signed overflow does not occur when simplifying conditional to constant' rjones at redhat dot com
2012-03-12 12:30 ` [Bug c/52560] " jim at meyering dot net
2012-03-12 13:23 ` [Bug tree-optimization/52560] " rguenth at gcc dot gnu.org
2012-03-12 16:31 ` rjones at redhat dot com
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).