Skip to content

Commit ae14c61

Browse files
Abseil Teamnetkex
authored andcommitted
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
1 parent dd5f1db commit ae14c61

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

absl/meta/type_traits.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,19 @@ using swap_internal::StdSwapIsUnconstrained;
501501
//
502502
// TODO(b/275003464): remove the opt-out once the bug is fixed.
503503
//
504+
// Starting with Xcode 15, the Apple compiler will falsely say a type
505+
// with a user-provided move constructor is trivially relocatable
506+
// (b/324278148). We will opt out without a version check, due to
507+
// the fluidity of Apple versions.
508+
//
509+
// TODO(b/324278148): If all versions we use have the bug fixed, then
510+
// remove the condition.
511+
//
504512
// According to https://github.com/abseil/abseil-cpp/issues/1479, this does not
505513
// work with NVCC either.
506514
#if ABSL_HAVE_BUILTIN(__is_trivially_relocatable) && \
507515
!(defined(__clang__) && (defined(_WIN32) || defined(_WIN64))) && \
508-
!defined(__NVCC__)
516+
!(defined(__APPLE__)) && !defined(__NVCC__)
509517
template <class T>
510518
struct is_trivially_relocatable
511519
: std::integral_constant<bool, __is_trivially_relocatable(T)> {};

absl/meta/type_traits_test.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,9 +792,12 @@ TEST(TriviallyRelocatable, UserProvidedDestructor) {
792792

793793
// TODO(b/275003464): remove the opt-out for Clang on Windows once
794794
// __is_trivially_relocatable is used there again.
795-
#if defined(ABSL_HAVE_ATTRIBUTE_TRIVIAL_ABI) && \
796-
ABSL_HAVE_BUILTIN(__is_trivially_relocatable) && \
797-
!(defined(__clang__) && (defined(_WIN32) || defined(_WIN64)))
795+
// TODO(b/324278148): remove the opt-out for Apple once
796+
// __is_trivially_relocatable is fixed there.
797+
#if defined(ABSL_HAVE_ATTRIBUTE_TRIVIAL_ABI) && \
798+
ABSL_HAVE_BUILTIN(__is_trivially_relocatable) && \
799+
!(defined(__clang__) && (defined(_WIN32) || defined(_WIN64))) && \
800+
!defined(__APPLE__)
798801
// A type marked with the "trivial ABI" attribute is trivially relocatable even
799802
// if it has user-provided move/copy constructors and a user-provided
800803
// destructor.

0 commit comments

Comments
 (0)