[PATCH] D87528: Enable '#pragma STDC FENV_ACCESS' in frontend cf. D69272 - Work in Progress
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 13 23:55:42 PDT 2020
rjmccall added a comment.
Richard, what do you think the right rule is for when to use the special constant-evaluation rules for this feature in C++? The C standard says that constant expressions should use the default rules rather than considering the dynamic environment, but C can get away with that because constant expressions are restricted to a narrow set of syntactic situations. In C++, [cfenv.syn]p1 says:
If the pragma is used to enable control over the floating-point environment, this document does not specify the effect on floating-point evaluation in constant expressions.
i.e. the standard punts to the implementation. So I think we need to actually formulate a policy for when something counts as a "constant expression" for the purposes of ignoring this pragma. Allow me to suggest:
- initializers for objects of static storage duration if they would be constant initializers if they weren't covered by the pragma; this should roughly align C and C++ semantics for things like `static const` within a function
- any `constexpr` / `constinit` context, and it should be ill-formed to use the pragma in such a context; that is, it's ignored from outside and prohibited (directly) inside
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87528/new/
https://reviews.llvm.org/D87528
More information about the cfe-commits
mailing list