[PATCH] D131143: [Clang] Interaction of FP pragmas and function template instantiation
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 4 11:08:17 PDT 2022
efriedma added a comment.
> In the case is explicit instantiation there is apparent connection
> between a point in source code and instantiated function. It can
> support interaction of pragmas that act in that point. For example, in
> the code:
>
> #pragma STDC FENV_ROUND FE_DOWNWARD
> template float func_05<short>(float, float);
>
> the instantiated function is created with the specified constant
> rounding mode. The effect is same as if the template pattern were
> textually inserted into the code with needed replacements.
These pragmas aren't currently part of the C++ standard, but I strongly doubt the C++ standards committee would choose to do this. You would end up with undefined behavior due to mismatched definitions, if the template is implicitly instantiated elsewhere.
The "obvious" rule here is just to always use the pragma in effect at the point the template body is written.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131143/new/
https://reviews.llvm.org/D131143
More information about the cfe-commits
mailing list