public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/10232: else clause is executed gratuitously
@ 2003-03-27 1:06 geoffk
0 siblings, 0 replies; 4+ messages in thread
From: geoffk @ 2003-03-27 1:06 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, p.van-hoof
Synopsis: else clause is executed gratuitously
State-Changed-From-To: open->closed
State-Changed-By: geoffk
State-Changed-When: Thu Mar 27 00:59:24 2003
State-Changed-Why:
Works as designed in 3.3. -ffast-math in 3.3 includes -fno-trapping-math, which does:
Compile code assuming that floating-point operations cannot
generate user-visible traps.
Crashing is 'user-visible', so if you want to crash on traps then you should not use -fno-trapping-math.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10232
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: optimization/10232: else clause is executed gratuitously
@ 2003-03-27 20:21 neroden
0 siblings, 0 replies; 4+ messages in thread
From: neroden @ 2003-03-27 20:21 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, p.van-hoof
Synopsis: else clause is executed gratuitously
State-Changed-From-To: closed->open
State-Changed-By: neroden
State-Changed-When: Thu Mar 27 20:12:16 2003
State-Changed-Why:
submitter's comments
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10232
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: optimization/10232: else clause is executed gratuitously
@ 2003-03-27 3:06 Peter van Hoof
0 siblings, 0 replies; 4+ messages in thread
From: Peter van Hoof @ 2003-03-27 3:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/10232; it has been noted by GNATS.
From: Peter van Hoof <p.van-hoof@qub.ac.uk>
To: geoffk@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org,
gcc-gnats@gcc.gnu.org
Cc:
Subject: Re: optimization/10232: else clause is executed gratuitously
Date: Thu, 27 Mar 2003 02:12:04 +0000
geoffk@gcc.gnu.org wrote:
> Works as designed in 3.3. -ffast-math in 3.3 includes -fno-trapping-math,
Agreed. However, in 3.2.2 the exception is triggered *without* specifying
-ffast-math, and is therefore in my view a bug. Shouldn't this be fixed in 3.2.3?
^ permalink raw reply [flat|nested] 4+ messages in thread
* optimization/10232: else clause is executed gratuitously
@ 2003-03-26 21:56 p.van-hoof
0 siblings, 0 replies; 4+ messages in thread
From: p.van-hoof @ 2003-03-26 21:56 UTC (permalink / raw)
To: gcc-gnats
>Number: 10232
>Category: optimization
>Synopsis: else clause is executed gratuitously
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Wed Mar 26 21:56:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Peter van Hoof
>Release: gcc 3.2.2
>Organization:
>Environment:
System: Linux tpol.pst.qub.ac.uk 2.4.18-27.7.x #1 Fri Mar 14 06:44:53 EST 2003 i686 unknown
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
Configured with: ../gcc-3.2.2/configure --prefix=/usr/local/gcc322
>Description:
In the program below, the else clause should never be executed. However, the (long)pp is executed nevertheless and triggers an FP exception because pp is too large to fit in a 32-bit integer. This bug is to some extent target specific; it is triggered for the following targets: i686, pentiumpro, pentium2, pentium3, athlon, athlon-tbird, athlon-4, athlon-xp, athlon-mp.
In order to trigger the bug with gcc 3.3, the flag -ffast-math needs to be added.
>How-To-Repeat:
tpol.pst.qub.ac.uk> gcc -O2 h.c
tpol.pst.qub.ac.uk> a.out
survived 2.15e+09 3
tpol.pst.qub.ac.uk> gcc -v -march=athlon -O2 h.c
Reading specs from /usr/local/gcc3/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.2.2/specs
Configured with: ../gcc-3.2.2/configure --prefix=/usr/local/gcc322
Thread model: posix
gcc version 3.2.2
/usr/local/gcc3/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.2.2/cc1 -lang-c -v -iprefix /usr/local/gcc3/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.2.2/ -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=2 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__OPTIMIZE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__athlon -D__athlon__ -D__tune_athlon__ -D__MMX__ -D__3dNOW__ -D__3dNOW_A__ h.c -quiet -dumpbase h.c -march=athlon -O2 -version -o /tmp/ccS2PZ2B.s
GNU CPP version 3.2.2 (cpplib) (i386 Linux/ELF)
GNU C version 3.2.2 (i686-pc-linux-gnu)
compiled by GNU C version 3.2.2.
ignoring nonexistent directory "/usr/local/gcc3/i686-pc-linux-gnu/include"
ignoring nonexistent directory "/usr/local/gcc322/i686-pc-linux-gnu/include"
ignoring duplicate directory "/usr/local/gcc322/lib/gcc-lib/i686-pc-linux-gnu/3.2.2/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/gcc3/lib/gcc-lib/i686-pc-linux-gnu/3.2.2/include
/usr/local/include
/usr/local/gcc322/include
/usr/include
End of search list.
as -V -Qy -o /tmp/ccSiJcG4.o /tmp/ccS2PZ2B.s
GNU assembler version 2.11.93.0.2 (i386-redhat-linux) using BFD version 2.11.93.0.2 20020207
/usr/local/gcc3/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.2.2/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o /usr/local/gcc3/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.2.2/crtbegin.o -L/usr/local/gcc3/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.2.2 -L/usr/local/gcc3/bin/../lib/gcc-lib -L/usr/local/gcc322/lib/gcc-lib/i686-pc-linux-gnu/3.2.2 -L/usr/local/gcc3/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.2.2/../../.. -L/usr/local/gcc322/lib/gcc-lib/i686-pc-linux-gnu/3.2.2/../../.. /tmp/ccSiJcG4.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/local/gcc3/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.2.2/crtend.o /usr/lib/crtn.o
tpol.pst.qub.ac.uk> a.out
Floating exception
tpol.pst.qub.ac.uk> cat h.c
/* INT_MAX+1 */
double pp = 2147483647. + 1.;
int main()
{
int nd;
/* make sure the program crashes on FP exception */
unsigned short int Mask;
__asm__ ("fnstcw %0" : "=m" (*&Mask));
Mask &= 0xFFF2;
__asm__ ("fldcw %0" : : "m" (*&Mask));
if( pp > 3. )
nd = 3;
else
nd = (long)pp;
printf( "survived %.2e %d\n", pp, nd );
return 0;
}
>Fix:
Workaround: optimize for a different target, or use -O1, or omit -ffast-math in the case of gcc 3.3
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-03-27 20:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-27 1:06 optimization/10232: else clause is executed gratuitously geoffk
-- strict thread matches above, loose matches on Subject: below --
2003-03-27 20:21 neroden
2003-03-27 3:06 Peter van Hoof
2003-03-26 21:56 p.van-hoof
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).