Bug 166463 - remquo[f] may return wrong sign in quo part and incorrect rem part on denormals
Summary: remquo[f] may return wrong sign in quo part and incorrect rem part on denormals
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: standards (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: David Schultz
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-28 13:40 UTC by Ilya Burylov
Modified: 2012-04-21 08:02 UTC (History)
0 users

See Also:


Attachments
file.diff (1.42 KB, patch)
2012-03-28 13:40 UTC, Ilya Burylov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ilya Burylov 2012-03-28 13:40:09 UTC
Currently we will get the wrong result as follows:

remquof(0x7bb33336, 0x63000000) = -671088640, 0x00000000 /* wrong sign in quo */
remquo(0xbff0000000000003, 0x3ff0000000000003) = 1, 0x8000000000000000 /* wrong sign in quo */
remquo(0x9120000000000001, 0x0000000000000005) = -1288490188, 0x0000000000000004 /* wrong quo and rem parts */

while [an example of] correct one should be:

remquof(0x7bb33336, 0x63000000) = 1476395008, 0x00000000
remquo(0xbff0000000000003, 0x3ff0000000000003) = -1, 0x8000000000000000
remquo(0x9120000000000001, 0x0000000000000005) = -1288490189, 0x0000000000000001

That does not fit into description in C99 standard: e.g. "In
the object pointed to by quo they store a value whose sign is the sign of x/y"

Fix attached

Fix: Fix should be applied to 
\msun\src\s_remquo.c
\msun\src\s_remquof.c

Fix attached.

Patch attached with submission follows:
How-To-Repeat: Reproducible in description
Comment 1 David Schultz freebsd_committer freebsd_triage 2012-04-07 04:38:23 UTC
Responsible Changed
From-To: freebsd-standards->das

This looks like the right fix.  I will look into it.
Comment 2 David Schultz freebsd_committer freebsd_triage 2012-04-07 05:00:10 UTC
State Changed
From-To: open->patched

Thanks for the bug report and the patch!  I've applied it in r233973, 
which fixes remquol() as well.
Comment 3 David Schultz freebsd_committer freebsd_triage 2012-04-21 08:01:12 UTC
State Changed
From-To: patched->closed

Merged to 7, 8, and 9-STABLE in revs 234533-234535.