[cfp-interest 3465] Action item re semantic rules for constant evaluation
Jim Thomas
jaswthomas at sbcglobal.net
Tue May 20 21:08:57 PDT 2025
The following addresses action item:
> Jim: Write up a suggestion re. semantic rules for constant evaluation.
>
Background:
In email to CFP, Vincent Lefevre noted that 6.6.1 #17 says
The semantic rules for the evaluation of a constant expression are the same as for nonconstant expressions.122)
and he commented “this cannot be true for status flags, as they cannot be raised at translation time.” One could argue that an implication that status flags are raised, or a statement that they are not raised, at translation time is inconsequential, since C doesn’t provide a way to access status flags at translation time.
However, a clear contradiction to 6.6.1 #17 is in 6.6.1 #5:
… If a floating expression is evaluated in the translation environment, the arithmetic range and precision shall be at least as great as if the expression were being evaluated in the execution environment.
which has been understood to mean that the translation environment can use more range and precision.
Note that this license is limited by the fact that evaluation methods characterized by the evaluation method macros (5.3.5.3.3) apply to both execution time and translation time evaluations (see footnote 117 in 6.6.1). Thus using more range and precision for translation time evaluation is not permitted under the standard specified evaluation methods.
The suggested change below qualifies 6.6.1 #17 to remove the contradiction.
Alternatively, 6.6.1 #17 could be deleted, because the semantic rules for evaluation of expressions don’t say they are just for execution time. However, #17 might be a helpful in highlighting a significant fact, and it provides an anchor for footnote 122.
Suggested change:
Change 6.6.1 #17 to:
The semantic rules for the evaluation of a constant expression are the same as for nonconstant expressions, unless explicitly stated otherwise.122)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20250520/91d2e518/attachment.htm>
More information about the cfp-interest
mailing list