optimization/8585: Linux-x86 optimization bug when using floor and log
bfkelly@nsa.gov
bfkelly@nsa.gov
Thu Nov 21 01:36:00 GMT 2002
>Number: 8585
>Category: optimization
>Synopsis: Linux-x86 optimization bug when using floor and log
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Nov 14 13:26:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Blair Kelly
>Release: gcc-3.2, gcc-20021111
>Organization:
>Environment:
Reading specs from /.ccs/home/bfkelly/gcc-3.2/Linux-x86/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs
Configured with: ../gcc-3.2/configure --enable-languages=c --prefix=/.ccs/home/bfkelly/gcc-3.2/Linux-x86
Thread model: posix
gcc version 3.2
>Description:
/* Demonstrates gcc-3.2 optimization bug
* on Linux-x86
*
* works correctly (says floor is 28)
* gcc -O0 -o foo foo.c -lm
*
* works incorrectly (says floor is 27)
* gcc -O1 -o foo foo.c -lm
*
* works incorrectly (says floor is 27)
* gcc -O2 -o foo foo.c -lm
*
*/
#include <stdio.h>
#include <math.h>
main()
{
double x, y, z;
x = 28.0;
printf("x= %f (%x %x)\n", x, *(&x), *((&x)+1));
y = floor(x);
printf("floor(x)= %f (%x %x)\n", y, *(&y), *((&y)+1));
z = 268435456.0; /* 2^28 */
x = log(z) / log(2.0);
printf("x= %f (%x %x)\n", x, *(&x), *((&x)+1));
y = floor(log(z) / log(2.0));
printf("floor(x)= %f (%x %x)\n", y, *(&y), *((&y)+1));
}
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-prs
mailing list