[libc-commits] [libc] 80deb82 - [libc][fenv] Add compile time check (#87826)
via libc-commits
libc-commits at lists.llvm.org
Fri Apr 5 14:50:16 PDT 2024
Author: Robin Caloudis
Date: 2024-04-05T17:49:46-04:00
New Revision: 80deb8269f2252b65c8af09da100e5b4949d589d
URL: https://github.com/llvm/llvm-project/commit/80deb8269f2252b65c8af09da100e5b4949d589d
DIFF: https://github.com/llvm/llvm-project/commit/80deb8269f2252b65c8af09da100e5b4949d589d.diff
LOG: [libc][fenv] Add compile time check (#87826)
Take care of a TODO. This
check makes sure that the fexcept_t
value fits in an int value.
TODO introduced in:
https://github.com/llvm/llvm-project/commit/9550f8ba9a3a697f28a7920c8aeb5cba1e8003a6
Added:
Modified:
libc/src/fenv/fegetexceptflag.cpp
Removed:
################################################################################
diff --git a/libc/src/fenv/fegetexceptflag.cpp b/libc/src/fenv/fegetexceptflag.cpp
index 71b87ce7315d1a..c6160da7afbde2 100644
--- a/libc/src/fenv/fegetexceptflag.cpp
+++ b/libc/src/fenv/fegetexceptflag.cpp
@@ -15,7 +15,8 @@
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(int, fegetexceptflag, (fexcept_t * flagp, int excepts)) {
- // TODO: Add a compile time check to see if the excepts actually fit in flagp.
+ static_assert(sizeof(int) >= sizeof(fexcept_t),
+ "fexcept_t value cannot fit in an int value.");
*flagp = static_cast<fexcept_t>(fputil::test_except(FE_ALL_EXCEPT) & excepts);
return 0;
}
More information about the libc-commits
mailing list