Bug 59412 - __fixunsdfDI triggers wrong inexact exceptions
Summary: __fixunsdfDI triggers wrong inexact exceptions
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcc (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 16989
  Show dependency treegraph
 
Reported: 2013-12-06 17:42 UTC by Aurelien Jarno
Modified: 2019-06-26 05:41 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aurelien Jarno 2013-12-06 17:42:14 UTC
__fixunsdfDI triggers an inexact exception even when converting an integer number from double to long long, while it shouldn't. This is due to this part of the code:

UDWtype
__fixunsdfDI (DFtype a)
{
  /* Get high part of result.  The division here will just moves the radix
     point and will not cause any rounding.  Then the conversion to integral
     type chops result as desired.  */
  const UWtype hi = a / Wtype_MAXp1_F;

As said in the comment, the division just moves the radix, so it doesn't triggers an inexact exception. However then the value then have some decimal parts and the convertsion from double to int triggers the inexact exception. This is reproducible for example on powerpc32 and causes errors in the glibc testsuite.
Comment 1 Joseph S. Myers 2015-10-12 17:33:10 UTC
Note that in addition to spurious "inexact" exceptions, this division can cause spurious "underflow" exceptions when converting tiny values to integer 0.  Other spurious exceptions can occur in overflow cases, when only "invalid" should be raised, and the signed conversions wrapping this function can fail to raise "invalid" for some overflow cases.
Comment 2 baoshan 2015-11-17 22:42:00 UTC
Why this has been unconfirmed for so long time? Can someone tell us if this is a bug in libgcc2.c or not? Thanks.
Comment 3 jsm-csl@polyomino.org.uk 2015-11-17 22:51:51 UTC
It's a bug in libgcc2.c for the subset of targets for which this code gets 
used (note 64-bit targets will generally be using it for TImode not 
DImode) *and* which have hardware exceptions.  It's part of the general 
large group of bugs relating to code generation / transformations not 
consistently accounting for exceptions / rounding modes.
Comment 4 baoshan 2015-11-17 23:33:43 UTC
(In reply to joseph@codesourcery.com from comment #3)
> It's a bug in libgcc2.c for the subset of targets for which this code gets 
> used (note 64-bit targets will generally be using it for TImode not 
> DImode) *and* which have hardware exceptions.  It's part of the general 
> large group of bugs relating to code generation / transformations not 
> consistently accounting for exceptions / rounding modes.

Hi Joseph,

Thanks for the quick response.
Do you know if there is fix for this issue? 

Thanks,
Baoshan
Comment 5 jsm-csl@polyomino.org.uk 2015-11-18 02:08:20 UTC
I'm not aware of anyone working on these exceptions / rounding modes 
issues.