public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: p.van-hoof@qub.ac.uk To: gcc-gnats@gcc.gnu.org Subject: optimization/10232: else clause is executed gratuitously Date: Wed, 26 Mar 2003 21:56:00 -0000 [thread overview] Message-ID: <20030326214910.7823.qmail@sources.redhat.com> (raw) >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:
next reply other threads:[~2003-03-26 21:56 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-03-26 21:56 p.van-hoof [this message] 2003-03-27 1:06 geoffk 2003-03-27 3:06 Peter van Hoof 2003-03-27 20:21 neroden
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20030326214910.7823.qmail@sources.redhat.com \ --to=p.van-hoof@qub.ac.uk \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).