Bug 111220

Summary: exp function from math lib returns wrong values
Product: [Retired] Red Hat Linux Reporter: Edward Pilipczuk <edward.pilipczuk>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: high Docs Contact:
Priority: medium    
Version: 9CC: fweimer
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-11-30 13:30:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Edward Pilipczuk 2003-11-30 12:29:31 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1)
Gecko/20030225

Description of problem:
as in summary -> small example test:
----
#include <stdio.h>
main(){
  int i;
  for(i=0;i<10;i++) 
    printf( "exp(%f)=%e ?\n", 1.0*i, exp( 1.0*i ) );
}
----
compiled with command 'gcc -O2 -lm -otest test.c'
produces for example such results...
----
exp(0.000000)=2.057234e+10 ?
exp(1.000000)=2.057234e+10 ?
exp(2.000000)=2.057234e+10 ?
exp(3.000000)=2.057234e+10 ?
exp(4.000000)=2.057234e+10 ?
exp(5.000000)=2.057234e+10 ?
exp(6.000000)=2.057234e+10 ?
exp(7.000000)=2.057234e+10 ?
exp(8.000000)=2.057234e+10 ?
exp(9.000000)=2.057234e+10 ?
----


Version-Release number of selected component (if applicable):
  glibc-2.3.2-27.9.7

How reproducible:
Always

Steps to Reproduce:  as in description

Actual Results:  as in description

Expected Results:  it is the lates glibc patch for RH9
I think new one is required that will have at least math revised...


Additional info:

Comment 1 Jakub Jelinek 2003-11-30 13:30:37 UTC
This is a bug in the example.  Functions without prototypes are assumed
to return int.  exp returns double, not int, so this really cannot
work correctly, especially on architectures which return floating point
values in different registers than integral ones.
If you add #include <math.h> to the example, it will work just fine.