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.0000    max :       0.0000
**
**      Compile with -ffast-math and things goes screwy.
**
**      > gcc -Wall -O3 -ffast-math gcc-test.c -o gcc-test && ./gcc-test 
**      min :   99999.0000    max :       0.0000
*/

#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 = -99999.0, min = 99999.0 ;
        int k ;

        for (k = 0 ; k < COUNT ; k++)
        {       max = test_max (max, data [k]) ;
                min = test_min (min, data [k]) ;
                } ;

        printf ("min : %12.4f    max : %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

Reply via email to