[libcxx-commits] [libcxx] [libc++] Workaround clang bug in __has_unique_object_representations (PR #95314)

Mital Ashok via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 13 08:15:17 PDT 2024


================
@@ -22,7 +23,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
-    : public integral_constant<bool, __has_unique_object_representations(_Tp)> {};
+    // TODO: We work around a Clang bug in __has_unique_object_representations by instantiating the
+    //       builtin on the non-array type first and discarding that. This is issue #95311.
+    //       This workaround can be removed once the bug has been fixed in all supported Clangs.
+    : public integral_constant<bool,
+                               ((void)__has_unique_object_representations(remove_all_extents_t<_Tp>),
+                                __has_unique_object_representations(_Tp))> {};
----------------
MitalAshok wrote:

Note that GCC 14 crashes without this workaround: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115476 so this will have to remain until we drop support for Clang 18 and GCC 14 (if this gets fixed in Clang 19 and GCC 15)


https://github.com/llvm/llvm-project/pull/95314


More information about the libcxx-commits mailing list