[libc-commits] [PATCH] D119145: [libc] Fix illegal type punning

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Feb 7 09:35:35 PST 2022


sivachandra added inline comments.


================
Comment at: libc/src/fenv/fesetexceptflag.cpp:28
                 "fexcept_t value cannot fit in an int value.");
-  int excepts_to_set = static_cast<const int>(*flagp) & excepts;
+  using IntType = TypeSelector<sizeof(fexcept_t)>::type;
+  const int excepts_as_int = __llvm_libc::bit_cast<IntType>(*flagp);
----------------
I am still confused. Previously, we de-referenced (`*flagp`) before static-casting it. So, there is no type-punning involved (assuming `fexcept_t` is of integral type), no? Can you share the error you are seeing?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119145/new/

https://reviews.llvm.org/D119145



More information about the libc-commits mailing list