__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.
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.
Why this has been unconfirmed for so long time? Can someone tell us if this is a bug in libgcc2.c or not? Thanks.
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.
(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
I'm not aware of anyone working on these exceptions / rounding modes issues.