[cfp-interest 3427] Re: constant expressions and floating-point exceptions
Vincent Lefevre
vincent at vinc17.net
Tue Apr 8 17:08:17 PDT 2025
On 2025-04-08 15:29:17 -0700, Jim Thomas wrote:
> 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.
OK. But something is not clear. A constant expression is allowed in
a context where such an expression is not required. For instance:
int main()
{
double x = 1 / 0;
...
}
Here, a constant expression is not required. So 1 / 0 may be
evaluated either at runtime or during translation as a constant
expression. If evaluated at runtime, some flags may be raised.
If evaluated during translation, is it required to raise these
flags at runtime to get the same semantic as runtime (6.6p17)?
> 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.
I don't see why they would differ.
> 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.
I don't understand why this would not be permitted. If I understand
correctly, the same rules need to be used at translation time and
at runtime (the same formats need to be used 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)
More information about the cfp-interest
mailing list