1 |
Hi |
2 |
I thought I should mention this here too in case anyone else gets |
3 |
bitten by this arm-gnueabi-softfloat-specific bug. |
4 |
|
5 |
A GCC bug has just turned up that affects the arm-*-gnueabi |
6 |
architecture in gcc-4.[123]. While debugging libvorbisenc (which |
7 |
produces silent output files on armel), it turns out that when -O |
8 |
-ffast-math are set, GCC can produce incorrect code for the max(x,y) |
9 |
macro applied to floating point values. |
10 |
|
11 |
Thanks to Erik de Castro Lopo for some incisive debugging and for |
12 |
producing a minimal example (should print "0 0" but doesn't) |
13 |
|
14 |
/* |
15 |
** This file is in the Public Domain. |
16 |
** |
17 |
** This program demonstrates a bug in the -ffast-math option of the gcc |
18 |
** armel compiler : gcc version 4.3.2 (Debian 4.3.2-1.1) |
19 |
** |
20 |
** This works as expected: |
21 |
** |
22 |
** > gcc -Wall -O3 gcc-test.c -o gcc-test && ./gcc-test |
23 |
** min : 0.0000 max : 0.0000 |
24 |
** |
25 |
** Compile with -ffast-math and things goes screwy. |
26 |
** |
27 |
** > gcc -Wall -O3 -ffast-math gcc-test.c -o gcc-test && ./gcc-test |
28 |
** min : 99999.0000 max : 0.0000 |
29 |
*/ |
30 |
|
31 |
#include <stdio.h> |
32 |
|
33 |
#define COUNT 10 |
34 |
|
35 |
#define test_max(x,y) ((x) < (y) ? (y) : (x)) |
36 |
#define test_min(x,y) ((x) > (y) ? (y) : (x)) |
37 |
|
38 |
int |
39 |
main (void) |
40 |
{ /* C Standard says static data gets initialized to zero. */ |
41 |
static float data [COUNT] ; |
42 |
float max = -99999.0, min = 99999.0 ; |
43 |
int k ; |
44 |
|
45 |
for (k = 0 ; k < COUNT ; k++) |
46 |
{ max = test_max (max, data [k]) ; |
47 |
min = test_min (min, data [k]) ; |
48 |
} ; |
49 |
|
50 |
printf ("min : %12.4f max : %12.4f\n", min, max) ; |
51 |
|
52 |
return 0 ; |
53 |
} |
54 |
|
55 |
Full details at http://bugs.debian.org/515949 |
56 |
|
57 |
M |