Subject: lib/153: hypot(3) gives incorrect results when compiled with -O
To: None <gnats-admin>
From: Matthieu Herrb <matthieu@laas.fr>
List: netbsd-bugs
Date: 03/03/1994 15:20:05
>Number: 153
>Category: lib
>Synopsis: hypot(3) gives incorrect results when compiled with -O
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: gnats-admin (Library Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Mar 3 15:20:04 1994
>Originator: Matthieu Herrb
>Organization:
CNRS - LAAS
7, avenue du Colonel Roche
31077 Toulouse Cedex - France
>Release: current of 26/02
>Environment:
486DX33 16M memory
System: NetBSD cougar 0.9a COUGAR#8 i386
>Description:
the __ieee754_hypot function returns the wrong answer in almost every
case when compiled with -O.
>How-To-Repeat:
The following program should print h = 1.00 for every i:
#include <stdio.h>
#include <math.h>
main()
{
double a, s, c, h,;
int i;
printf(" i a h\n");
for (i = 0; i <= 360; i++) {
a = M_PI*i/180;
s = sin(a1);
c = cos(a1);
h = hypot(s, c);
printf("%3d %7.4f %7.4f\n",
i, a, h);
}
}
>Fix:
Workaround: compile e_hypot.c without -O
>Audit-Trail:
>Unformatted:
------------------------------------------------------------------------------