[libcxx-commits] [PATCH] D143902: [libc++] Extend is_always_bitcastable for pointers and enums

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 27 09:23:48 PST 2023


ldionne added a comment.

CC @var-const



================
Comment at: libcxx/include/__type_traits/is_always_bitcastable.h:40-42
+  static const bool value =
+      (sizeof(_From) == sizeof(_To)) && is_object<_UnqualFrom>::value && is_object<_UnqualTo>::value &&
+      (is_same<_UnqualFrom, _UnqualTo>::value || is_void<_UnqualFrom>::value || is_void<_UnqualTo>::value);
----------------
WDYT?


================
Comment at: libcxx/include/__type_traits/is_always_bitcastable.h:73
     //   unsigned...
+    // - enumerations to integral types...
     // - as well as arrays of such types...
----------------



================
Comment at: libcxx/include/__type_traits/is_always_bitcastable.h:87
+    // - enumeration types may have different ranges of possible values (fails #1)
+    //   enumerations to integers of the same size are valid
     // - for pointers, it is not guaranteed that pointers to different types use the same set of values to represent
----------------



================
Comment at: libcxx/include/__type_traits/is_always_bitcastable.h:88-90
     // - for pointers, it is not guaranteed that pointers to different types use the same set of values to represent
     //   addresses, and the conversion results are explicitly unspecified for types with different alignments
     //   (fails #1);
----------------
And then remove the line you added below.


================
Comment at: libcxx/test/libcxx/type_traits/is_always_bitcastable.compile.pass.cpp:61
 }
 
 template <bool Expected, class Types1, class Types2>
----------------
Can you please also add tests for `copy` and `move` that use these types? This is a really fundamental part of the library so we want to make sure our tests in that area are bomb proof.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143902



More information about the libcxx-commits mailing list