[libc-commits] [clang] [libc] Add clang warning if fp exception functions are called without appropriate flags/pragmas (PR #199009)

via libc-commits libc-commits at lists.llvm.org
Thu May 28 07:30:57 PDT 2026


================
@@ -37,26 +37,41 @@
 namespace LIBC_NAMESPACE_DECL {
 namespace fputil {
 
-LIBC_INLINE int clear_except(int excepts) { return feclearexcept(excepts); }
+LIBC_INLINE int clear_except(int excepts) {
+#pragma STDC FENV_ACCESS ON
----------------
lntue wrote:

Can you move libc changes to a separate PR?  Currently we disable this warning so your PR shouldn't break anything from us? https://github.com/llvm/llvm-project/blob/main/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake#L327

The main reason is that it will be a lot more involved to add this pragma due to compatibility issues with other targets and compilers:
https://godbolt.org/z/dcYheosoY

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


More information about the libc-commits mailing list