public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/8585: Linux-x86 optimization bug when using floor and log
@ 2002-11-21  1:36 bfkelly
  0 siblings, 0 replies; only message in thread
From: bfkelly @ 2002-11-21  1:36 UTC (permalink / raw)
  To: gcc-gnats


>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:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-11-14 21:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-21  1:36 optimization/8585: Linux-x86 optimization bug when using floor and log bfkelly

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).