Bug#513007: gcc-4.3/alpha: -foptimize-sibling-calls generates wrong code
Package: gcc-4.3
Version: 4.3.2-4
Severity: important
gcc-4.3 on alpha generates wrong code when -foptimize-sibling-calls is
used (which is enabled at -O2). It was not the case with gcc 4.2, and
this is still reproducible with gcc from trunk from 20090106. This is
the reason why most of the complex tests of the glibc testsuite are
failing with gcc-4.3.
Here is a reduced testcase:
$ cat main.c
#include <math.h>
#include <complex.h>
__complex__ float my_print_complex (__complex__ float x);
int main()
{
__complex__ float a;
__real__ a = 9;
__imag__ a = 42;
my_print_complex(a);
return 0;
}
$ cat print.c
#include <complex.h>
#include <math.h>
#include <stdio.h>
__complex__ float internal_print_complex (__complex__ float x)
{
printf("%f+%fi\n", __real__ x, __imag__ x);
if (__real__ x < 0)
{
__real__ x = -__real__ x;
}
return x;
}
__complex__ float my_print_complex (__complex__ float x)
{
return internal_print_complex (x);
}
$ gcc-4.3 -Wall -c main.c -o main.o
$ gcc-4.3 -O1 -foptimize-sibling-calls -Wall -c print.c -o print.o
$ gcc-4.3 -o test main.o print.o
$ ./test
0.000000+0.000000i
When print.o is not compiled with -foptimize-sibling-calls, the result
is:
$./test
9.000000+42.000000i
$
-- System Information:
Debian Release: 5.0
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: alpha
Reply to: