On Apple, implement absl::is_trivially_relocatable with the fallback.

The Apple implementation gives false positives starting with
Xcode 15.

PiperOrigin-RevId: 605726702
Change-Id: I2e5e574eca08071d24e97304f005cf9c78230913
diff --git a/absl/meta/type_traits.h b/absl/meta/type_traits.h
index cf71164..a456ae4 100644
--- a/absl/meta/type_traits.h
+++ b/absl/meta/type_traits.h
@@ -501,11 +501,19 @@
 //
 // TODO(b/275003464): remove the opt-out once the bug is fixed.
 //
+// Starting with Xcode 15, the Apple compiler will falsely say a type
+// with a user-provided move constructor is trivially relocatable
+// (b/324278148). We will opt out without a version check, due to
+// the fluidity of Apple versions.
+//
+// TODO(b/324278148): If all versions we use have the bug fixed, then
+// remove the condition.
+//
 // According to https://github.com/abseil/abseil-cpp/issues/1479, this does not
 // work with NVCC either.
 #if ABSL_HAVE_BUILTIN(__is_trivially_relocatable) &&                 \
     !(defined(__clang__) && (defined(_WIN32) || defined(_WIN64))) && \
-    !defined(__NVCC__)
+    !(defined(__APPLE__)) && !defined(__NVCC__)
 template <class T>
 struct is_trivially_relocatable
     : std::integral_constant<bool, __is_trivially_relocatable(T)> {};
diff --git a/absl/meta/type_traits_test.cc b/absl/meta/type_traits_test.cc
index 7412f33..8f92690 100644
--- a/absl/meta/type_traits_test.cc
+++ b/absl/meta/type_traits_test.cc
@@ -792,9 +792,12 @@
 
 // TODO(b/275003464): remove the opt-out for Clang on Windows once
 // __is_trivially_relocatable is used there again.
-#if defined(ABSL_HAVE_ATTRIBUTE_TRIVIAL_ABI) &&      \
-    ABSL_HAVE_BUILTIN(__is_trivially_relocatable) && \
-    !(defined(__clang__) && (defined(_WIN32) || defined(_WIN64)))
+// TODO(b/324278148): remove the opt-out for Apple once
+// __is_trivially_relocatable is fixed there.
+#if defined(ABSL_HAVE_ATTRIBUTE_TRIVIAL_ABI) &&                      \
+    ABSL_HAVE_BUILTIN(__is_trivially_relocatable) &&                 \
+    !(defined(__clang__) && (defined(_WIN32) || defined(_WIN64))) && \
+    !defined(__APPLE__)
 // A type marked with the "trivial ABI" attribute is trivially relocatable even
 // if it has user-provided move/copy constructors and a user-provided
 // destructor.