[cfp-interest 3426] Re: constant expressions and floating-point exceptions
Jim Thomas
jaswthomas at sbcglobal.net
Tue Apr 8 15:29:17 PDT 2025
Thoughts on [cfp-interest 3419] …
An implication that status flags are raised, or a statement that they are not raised, at translation time seems inconsequential, since C doesn’t provide a way to access status flags at translation time.
F.8.4 requires that the status flags be cleared at program startup.
I believe C would allow a non Annex F implementation to start execution with status flags resulting from translation time.
Another issue with 6.6 #17: The semantic rules for the evaluation of constant expressions vs nonconstant expressions differ in that constant expressions may (for implementation-defined or indeterminant evaluation methods, per 5.3.5.3.3) be evaluated with more range and precision. The evaluation methods characterized by the evaluation method macros or resulting from evaluation method pragmas apply to both execution time and translation time evaluations. Thus using extra range and precision for translation time evaluation is not permitted under the standard specified evaluation methods.
Could the semantic rules for evaluation that 6.6 #17 refers to be made more explicit?
- Jim Thomas
> On Mar 19, 2025, at 5:59 AM, Vincent Lefevre <vincent at vinc17.net> wrote:
>
> Hi,
>
> (I'm several months late in reading messages, but the following
> has never been mentioned, AFAIK.)
>
> About 6.6 Constant expressions, the constraints do not exclude
> floating-point exceptions, so that any of them may occur
> ("inexact", "overflow", "underflow", but also "divide-by-zero"
> with 1.0/0.0 and "invalid" with 0.0/0.0 when defined, e.g. with
> Annex F - ISO/IEC 60559 floating-point arithmetic).
>
> However, 6.6p17 says
>
> The semantic rules for the evaluation of a constant expression
> are the same as for nonconstant expressions.
>
> But this cannot be true for status flags, as they cannot be raised
> at translation time.
>
> --
> 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 / Pascaline 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