summaryrefslogtreecommitdiff
path: root/absl/meta/type_traits.h
diff options
context:
space:
mode:
authorGravatar Aaron Jacobs <jacobsa@google.com>2023-03-27 16:08:18 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-03-27 16:08:57 -0700
commit6b4af2497bf3ec56b070fdd6d8c2cf5996c17dbe (patch)
tree010891fa4aa2f51f8b4263033e3c80d980d43d6a /absl/meta/type_traits.h
parent0dc94309d367001176962db4ed3dc450a6448b31 (diff)
type_traits: don't use __is_trivially_relocatable with Clang on Windows.
It currently gives the wrong result for types with a user-provided destructor: struct S { ~S(); }; static_assert(!__is_trivially_relocatable(S)); PiperOrigin-RevId: 519855600 Change-Id: I5f0659ad0831974805a5ed4b615e3b6250d23154
Diffstat (limited to 'absl/meta/type_traits.h')
-rw-r--r--absl/meta/type_traits.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/absl/meta/type_traits.h b/absl/meta/type_traits.h
index f713b78c..43bed500 100644
--- a/absl/meta/type_traits.h
+++ b/absl/meta/type_traits.h
@@ -495,11 +495,18 @@ using swap_internal::StdSwapIsUnconstrained;
// Upstream documentation:
//
// https://clang.llvm.org/docs/LanguageExtensions.html#:~:text=__is_trivially_relocatable
-//
-#if ABSL_HAVE_BUILTIN(__is_trivially_relocatable)
+
// If the compiler offers a builtin that tells us the answer, we can use that.
// This covers all of the cases in the fallback below, plus types that opt in
// using e.g. [[clang::trivial_abi]].
+//
+// Clang on Windows has the builtin, but it falsely claims types with a
+// user-provided destructor are trivial (http://b/275003464). So we opt out
+// there.
+//
+// TODO(b/275003464): remove the opt-out once the bug is fixed.
+#if ABSL_HAVE_BUILTIN(__is_trivially_relocatable) && \
+ !(defined(__clang__) && (defined(_WIN32) || defined(_WIN64)))
template <class T>
struct is_trivially_relocatable
: std::integral_constant<bool, __is_trivially_relocatable(T)> {};