On Thu, 30 Jan 2014, Andreas Krebbel wrote:

> @@ -81,6 +91,8 @@ __fixdfdi (double a1)
>       l = (long long)1<<63;
>       if (!SIGND(dl1))
>           l--;
> +     /* C99 Annex F.4 requires an "invalid" exception to be thrown.  */
> +     fexceptdiv (0.0, 0.0);
>       return l;

My understanding of this code is that the condition exp >= 11 means a 
number with magnitude at least 0x1p63.  If the number is exactly -0x1p63, 
then the result of the most negative "long long" value should not involve 
the "invalid" exception.

> @@ -78,6 +88,8 @@ __fixsfdi (float a1)
>       l = (long long)1<<63;
>       if (!SIGN(fl1))
>           l--;
> +     /* C99 Annex F.4 requires an "invalid" exception to be thrown.  */
> +     fexceptdiv (0.0, 0.0);
>       return l;

Likewise.

> @@ -90,6 +100,8 @@ __fixtfdi (long double a1)
>         or more.  */
>      if (exp >= 0)
>        {
> +     /* C99 Annex F.4 requires an "invalid" exception to be thrown.  */
> +     fexceptdiv (0.0, 0.0);
>       l = 1ULL << 63; /* long long min */
>       return SIGND (dl1) ? l : l - 1;

Likewise, except in this case there are also values whose integer part is 
LLONG_MIN but whose fractional part is nonzero, for which "invalid" should 
also not be raised.

(This complication only arises for conversion to signed integers, not for 
conversion to unsigned.  But for the conversions to unsigned, you need to 
raise "invalid" for arguments <= -1, which your patch doesn't seem to do.)

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to