i386/51210: gcc compiler bug with floating point

ura at euro-bill.net ura at euro-bill.net
Mon Apr 21 04:20:17 PDT 2003


>Number:         51210
>Category:       i386
>Synopsis:       gcc compiler bug with floating point
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 21 04:20:15 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        FreeBSD 5.0-RELEASE-p7 i386
>Organization:
>Environment:
/etc/make.conf
CPUTYPE=p4
CFLAGS=-O2 -pipe
COPTFLAGS=-O2 -pipe

ttyp4 ~> gcc -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.2.1 [FreeBSD] 20021119 (release)

>Description:
When libm(msun) built with -march=pentium4, pow(3) returns incorrect
results.
>How-To-Repeat:
You must have pentium4 processor.

Compile whole system with specified /etc/make.conf (actually you
can compile only libm with this flags).

And try to compile this piece of code:
----[Cut]-----
#include <stdio.h>
#include <math.h>

int
main ()
{
        double res = pow(0.001953125F, 2.2000000476837158F);
        printf("%f", res);
}
----[Cut]-----
You will get 512.0000 (shoud be 0.000001)

>Fix:
I've found a workaround. Seems that gcc do not have such bug with
-march=pentium3. So if you replace
CPUTYPE=p4
to
CPUTYPE=p3
problem will be solved.
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list