Skip to content

Commit 80deb82

Browse files
[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: 9550f8b
1 parent 65e5391 commit 80deb82

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libc/src/fenv/fegetexceptflag.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
namespace LIBC_NAMESPACE {
1616

1717
LLVM_LIBC_FUNCTION(int, fegetexceptflag, (fexcept_t * flagp, int excepts)) {
18-
// TODO: Add a compile time check to see if the excepts actually fit in flagp.
18+
static_assert(sizeof(int) >= sizeof(fexcept_t),
19+
"fexcept_t value cannot fit in an int value.");
1920
*flagp = static_cast<fexcept_t>(fputil::test_except(FE_ALL_EXCEPT) & excepts);
2021
return 0;
2122
}

0 commit comments

Comments
 (0)