[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:58:55 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:
I don't think the fallback works:
```
// Portable fallback for GCC, MSVC, or older clang.
#define LIBC_FENV_ACCESS_ON _Pragma("STDC FENV_ACCESS ON")
```
https://godbolt.org/z/8bcdxojj9
We could add a compiler check to https://github.com/llvm/llvm-project/blob/main/libc/cmake/modules/CheckCompilerFeatures.cmake
and pass that definition to all libc's targets.
You also need to remove the (Wno-fenv-access) flag that we added.
Let's move it to a separate PR if it doesn't break this PR.
https://github.com/llvm/llvm-project/pull/199009
More information about the libc-commits
mailing list