[PATCH] D131143: [Clang] Interaction of FP pragmas and function template instantiation

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 5 09:37:40 PDT 2022

sepavloff added a comment.

In D131143#3700373 <https://reviews.llvm.org/D131143#3700373>, @efriedma wrote:

>> 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:
>>   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.

This is an attempt to implement the interaction as proposed in the review of D129464 <https://reviews.llvm.org/D129464>. It is, of course, an extension, which may be convenient but nothing serious would happen if it is not implemented.

> You would end up with undefined behavior due to mismatched definitions, if the template is implicitly instantiated elsewhere.

Indeed, it makes the solution fragile.

> The "obvious" rule here is just to always use the pragma in effect at the point the template body is written.

Sure, it is already works in this way.

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list