Bug 473974

Summary: cos() returns incorrect value in FE_UPWARD rounding mode
Product: [Fedora] Fedora Reporter: Alexander Kruppa <kruppaal>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 9CC: drepper
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-12-02 01:35:40 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:
Attachments:
Description Flags
Test case for incorrect value of cos() none

Description Alexander Kruppa 2008-12-01 17:08:52 UTC
Created attachment 325265 [details]
Test case for incorrect value of cos()

Description of problem:
The attached test case produces the erroneous value of -20763584.029346 for
cos(Pi / 2) when the rounding mode is set to FE_UPWARD, instead of the
correct value (close to) 0. Other rounding modes do not show this error,
compiling with optimization enabled (-O1, -O2 or -O3) or as a 32 bit binary
with -m32 also do not show the error. If the binary is linked statically with
-static, the bug disappears as well.


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

gcc (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)
glibc-2.8-8.x86_64 (Build Date: Thu Jul 17 00:31:06 2008)


How reproducible:

Steps to Reproduce:
1.Compile attached test case with
gcc -O0 -o cos_bug cos_bug.c -lm

2. run "./cos_bug"

  
Actual results:

Prints 
x = 1.57079632679489655800 = 0x1.921fb54442d18p+0
cos(x) = -20763584.029346


Expected results:

cos(x) should be a value close to 0.


Additional info:

Processor is Intel(R) Core(TM)2 CPU 6400  @ 2.13GHz.

May be related to bug #88513

Comment 1 Jakub Jelinek 2008-12-01 17:18:34 UTC
These routines aren't supposed to be called in non-standard rounding mode.
That's the caller's fault.

Comment 2 Ulrich Drepper 2008-12-02 01:35:40 UTC
What Jakub said.  The routines can only be called in the default mode.  Programs changing the mode have to (temporarily) change it back before calling into the library.