[clang] [clang] Do not clear FP pragma stack when instantiating functions (PR #70646)

Serge Pavlov via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 9 08:49:11 PST 2023


spavloff wrote:

`pragma pack` uses pragma stack and it is allowed in any place: https://godbolt.org/z/f8fP1vn63 . If such pragma presents in the late-parsed template, and push-pop operations in it are not balanced, the late parse of such function can break the pragma stack and next templates can be parsed incorrectly. It is not a FP pragma, but it demonstrates that the compiler must provide some Sema state isolation for late parsed templates.

For floating-point pragmas the stack could be cleared once, before the late parsing takes place. However it is complicated by the fact that the pragma stack set in precompiled header must be available in the unit that uses the header. Another complication is implicit assumption in some places that the default FP options are defined by LangOpts. It is not true, in some cases target may modify the default state (i386 is an example).

This fix is not optimal. The problems mentioned above are solvable and they should be fixed. However to have a quick solution for the initial PR the fix probably could be used.


https://github.com/llvm/llvm-project/pull/70646


More information about the cfe-commits mailing list