public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/19056] New: 4.0 optimizes away a SEGV; 3.4.1 does not
@ 2004-12-17 15:15 bh at techhouse dot brown dot edu
2004-12-17 15:19 ` [Bug c/19056] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: bh at techhouse dot brown dot edu @ 2004-12-17 15:15 UTC (permalink / raw)
To: gcc-bugs
A minimized test case:
int main() {
int y = 1;
int *x = &y;
volatile int sum = 0;
while(1) {
sum += *x;
x++;
}
return 0;
}
Clearly, this should crash; under 3.4.1 it does. Under my checkout of a few
hours ago, however, it does not: instead, it enters an infinite loop (everything
inside the while(1) gets optimized away and we're left with just a jmp).
Workaround: make either x or sum volatile. This forces it to actually do the
computations inside the loop.
I'm not sure whether to view this as a compiler bug: this code is, at heart,
morally unbalanced. But it is a change in behaviour so I figured I'd report it.
--
Summary: 4.0 optimizes away a SEGV; 3.4.1 does not
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bh at techhouse dot brown dot edu
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19056
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/19056] 4.0 optimizes away a SEGV; 3.4.1 does not
2004-12-17 15:15 [Bug c/19056] New: 4.0 optimizes away a SEGV; 3.4.1 does not bh at techhouse dot brown dot edu
@ 2004-12-17 15:19 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-17 15:19 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-12-17 15:18 -------
The code is undefined, once you get into that, anything can happen so closing as invalid.
We just optimize away the add and the load since the load is no longer needed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19056
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-12-17 15:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-17 15:15 [Bug c/19056] New: 4.0 optimizes away a SEGV; 3.4.1 does not bh at techhouse dot brown dot edu
2004-12-17 15:19 ` [Bug c/19056] " pinskia at gcc dot gnu dot 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).