[Cfp-interest 2137] Re: defect in ISO C about underflow with exact subnormal

Jim Thomas jaswthomas at sbcglobal.net
Sun Sep 12 18:39:08 PDT 2021



> On Aug 18, 2021, at 7:29 AM, Vincent Lefevre <vincent at vinc17.net> wrote:
> 
> On 2021-08-17 14:02:43 -0500, Rajan Bhakta wrote:
>>    Jim: [CFP 1997]: Range error definitions of overflow and underflow.
>>      See many CFP messages (Ex. CFP 2038-2090).
>>      Re CFP 2090:
>>      Jim: This would be a replacement of N2746.
>>      Fred: An exact subnormal is an underflow.
>>      Jim: Yes.
>>      Fred: In 754 it may not raise the underflow exception.
>>      Jim: Correct.
> [...]
> 
> The IEEE 754 standard says:
> 
>  In addition, under default exception handling for underflow, if the
>  rounded result is inexact — that is, it differs from what would have
>  been computed were both exponent range and precision unbounded — the
>  underflow flag shall be raised and the inexact (see 7.6) exception
>  shall be signaled. If the rounded result is exact, no flag is raised
>  and no inexact exception is signaled. This is the only case in this
>  standard of an exception signal receiving default handling that does
>  not raise the corresponding flag. Such an underflow signal has no
>  observable effect under default handling.
> 
> Thus if the exception handling is not the default one, an exact
> subnormal may yield non-default behavior.
> 
> In ISO C17 and the current C2x draft (N2596),
> F.9.2 "Expression transformations":
> 
>  1 × x and x/1 → x     The expressions 1 × x, x/1, and x may be
>                        regarded as equivalent (on IEC 60559 machines,
>                        among others).399)
> 
>  399) Strict support for signaling NaNs — not required by this
>  specification — would invalidate these and other transformations
>  that remove arithmetic operators.
> 
> is incorrect under non-default exception handling, because if x is
> a subnormal, 1 × x and x/1 may have a behavior different from just
> returning x.

C Annex F requires default exception handling and doesn’t provide a way to change to alternate exception handling. In this context the statement is correct. 

However, this issue needs to be mentioned in the update to TS-5 which includes alternate exception handling.

- Jim Thomas

> 
> -- 
> Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest




More information about the Cfp-interest mailing list