public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/25329] New: Miscompilation in tcl, -INT_MIN test misoptimized
@ 2005-12-09 17:11 matz at suse dot de
2005-12-09 17:12 ` [Bug tree-optimization/25329] " pinskia at gcc dot gnu dot org
2006-03-23 15:17 ` pinskia at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: matz at suse dot de @ 2005-12-09 17:11 UTC (permalink / raw)
To: gcc-bugs
This testcase:
------------------------------------
int bla (long l)
{
long lR;
if (l < 0) {
lR = - l;
if (lR < 0) { // 2
return 1;
}
}
return 0;
}
extern void abort ();
int main()
{
if (!bla (-2147483648))
abort ();
return 0;
}
----------------------------------
when compiled with -O2 will abort. because the inner test 2 will
be optimized away. The variable lR is negative at that point, but
the test won't trigger as it was removed. This same code is used in
tcl 8.4.12 to detect if the passed number is the most negative one (like in
the above example), and special case that one. So this code relies on
the fact that -INT_MIN is INT_MIN again, and hence both <0 test will
trigger.
Now, with -fwrapv this testcase is not miscompiled, but I'm not sure
if this behaviour of GCC is really justified by the standard and our
intention. Certainly the -INT_MIN stored into an int is implementation
defined, and older GCCs (and in fact also the current one) stores INT_MIN
into the target. Just deleting the test seems wrong.
--
Summary: Miscompilation in tcl, -INT_MIN test misoptimized
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: matz at suse dot de
GCC host triplet: i386-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25329
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/25329] Miscompilation in tcl, -INT_MIN test misoptimized
2005-12-09 17:11 [Bug tree-optimization/25329] New: Miscompilation in tcl, -INT_MIN test misoptimized matz at suse dot de
@ 2005-12-09 17:12 ` pinskia at gcc dot gnu dot org
2006-03-23 15:17 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-12-09 17:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2005-12-09 17:12 -------
-INT_MIN overflows so this is undefined so GCC is correct in assuming anything.
So the bug is in TCL.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25329
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/25329] Miscompilation in tcl, -INT_MIN test misoptimized
2005-12-09 17:11 [Bug tree-optimization/25329] New: Miscompilation in tcl, -INT_MIN test misoptimized matz at suse dot de
2005-12-09 17:12 ` [Bug tree-optimization/25329] " pinskia at gcc dot gnu dot org
@ 2006-03-23 15:17 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-23 15:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2006-03-23 15:17 -------
*** Bug 26824 has been marked as a duplicate of this bug. ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |simonmar at microsoft dot
| |com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25329
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-03-23 15:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-09 17:11 [Bug tree-optimization/25329] New: Miscompilation in tcl, -INT_MIN test misoptimized matz at suse dot de
2005-12-09 17:12 ` [Bug tree-optimization/25329] " pinskia at gcc dot gnu dot org
2006-03-23 15:17 ` 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).