Bug#515949: Simple test case for gcc -ffast-math bug
The following test case shows the failure when compiling with -ffast-math gives a different result than when compiling with out it. More explanation in the comments at the top of the file. Cheers, Erik /* ** This file is in the Public Domain. ** ** This program demonstrates a bug in the -ffast-math option of the gcc ** armel compiler : gcc version 4.3.2 (Debian 4.3.2-1.1) ** ** This works as expected: ** ** gcc -Wall -O3 gcc-test.c -o gcc-test ./gcc-test ** min : 0.max : 0. ** ** Compile with -ffast-math and things goes screwy. ** ** gcc -Wall -O3 -ffast-math gcc-test.c -o gcc-test ./gcc-test ** min : 9.max : 0. */ #include stdio.h #define COUNT 10 #define test_max(x,y) ((x) (y) ? (y) : (x)) #define test_min(x,y) ((x) (y) ? (y) : (x)) int main (void) { /* C Standard says static data gets initialized to zero. */ static float data [COUNT] ; float max = -9.0, min = 9.0 ; int k ; for (k = 0 ; k COUNT ; k++) { max = test_max (max, data [k]) ; min = test_min (min, data [k]) ; } ; printf (min : %12.4fmax : %12.4f\n, min, max) ; return 0 ; } -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#515949: Simple test case for gcc -ffast-math bug
On Thu, Mar 19, 2009 at 05:22:11PM +1100, Erik de Castro Lopo wrote: The following test case shows the failure when compiling with -ffast-math gives a different result than when compiling with out it. More explanation in the comments at the top of the file. Cheers, Erik /* **This file is in the Public Domain. ** **This program demonstrates a bug in the -ffast-math option of the gcc **armel compiler : gcc version 4.3.2 (Debian 4.3.2-1.1) ** **This works as expected: ** ** gcc -Wall -O3 gcc-test.c -o gcc-test ./gcc-test **min : 0.max : 0. ** **Compile with -ffast-math and things goes screwy. ** ** gcc -Wall -O3 -ffast-math gcc-test.c -o gcc-test ./gcc-test **min : 9.max : 0. */ I get the following results: (sid)kroe...@agricola:~$ gcc -O1 -ffinite-math-only tst.c -o tst (sid)kroe...@agricola:~$ ./tst min : 9.max : -9. (sid)kroe...@agricola:~$ gcc -O3 -ffinite-math-only tst.c -o tst (sid)kroe...@agricola:~$ ./tst min : 9.max : 0. With gcc version 4.3.3 (Debian 4.3.3-5) agricola is an armel running on a Thecus N2100: Processor : XScale-80219 rev 0 (v5l) BogoMIPS: 593.10 Features: swp half thumb fastmult edsp CPU implementer : 0x69 CPU architecture: 5TE CPU variant : 0x0 CPU part: 0x2e3 CPU revision: 0 I've also tried this on ia64, hppa, mips, mipsel and arm, they all gave the expected output. I will clone this bug to gcc and file a bug upstream. Kurt -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#515949: Simple test case for gcc -ffast-math bug
On Thu, Mar 19, 2009 at 06:53:45PM +0100, Kurt Roeckx wrote: I will clone this bug to gcc and file a bug upstream. It seems Martin Guy already reported it upstream: http://gcc.gnu.org/PR39501 http://gcc.gnu.org/PR39507 Kurt -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org