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

Guillaume Chatelet via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Feb 7 07:43:25 PST 2022


gchatelet created this revision.
gchatelet added reviewers: lntue, sivachandra.
Herald added subscribers: libc-commits, ecnelises, tschuett, mgorny.
Herald added a project: libc-project.
gchatelet requested review of this revision.

Although type punning is defined in C, it is UB in C++.
This patch introduces a bit_cast function to convert between types in a safe way.

This is necessary to get llvm-libc compile with GCC.
This patch is extracted from D119002 <https://reviews.llvm.org/D119002>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119145

Files:
  libc/src/__support/CPP/Bit.h
  libc/src/__support/CPP/CMakeLists.txt
  libc/src/__support/FPUtil/FPBits.h
  libc/src/__support/FPUtil/Hypot.h
  libc/src/__support/FPUtil/ManipulationFunctions.h
  libc/src/__support/FPUtil/generic/sqrt.h
  libc/src/__support/FPUtil/x86_64/LongDoubleBits.h
  libc/src/__support/FPUtil/x86_64/NextAfterLongDouble.h
  libc/src/__support/FPUtil/x86_64/sqrt.h
  libc/src/fenv/fesetexceptflag.cpp
  libc/src/math/generic/log10f.cpp
  libc/src/math/generic/log2f.cpp
  libc/src/math/generic/logf.cpp
  libc/src/math/generic/math_utils.h
  libc/src/string/memory_utils/CMakeLists.txt
  libc/src/string/memory_utils/elements_x86.h
  libc/test/src/math/NextAfterTest.h
  libc/test/src/math/SqrtTest.h
  utils/bazel/llvm-project-overlay/libc/BUILD.bazel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119145.406465.patch
Type: text/x-patch
Size: 23495 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20220207/53b3ec76/attachment-0001.bin>


More information about the libc-commits mailing list