Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions common/values/value_variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -732,11 +732,14 @@ class alignas(kValueVariantAlign) CEL_COMMON_INTERNAL_VALUE_VARIANT_TRIVIAL_ABI
const bool rhs_trivial =
(rhs.flags_ & ValueFlags::kNonTrivial) == ValueFlags::kNone;
if (lhs_trivial && rhs_trivial) {
// We validated the instances can be copied byte-wise at runtime, but compilers
// warn since this is not safe in the general case.
#if defined(__GNUC__) && !defined(__clang__)
// We validated the instances can be copied byte-wise at runtime, but GCC
// warns since this is not safe in the general case.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnontrivial-memcall"
#endif
alignas(ValueVariant) std::byte tmp[sizeof(ValueVariant)];
// NOLINTNEXTLINE(bugprone-undefined-memory-manipulation)
Expand All @@ -748,6 +751,8 @@ class alignas(kValueVariantAlign) CEL_COMMON_INTERNAL_VALUE_VARIANT_TRIVIAL_ABI
std::memcpy(std::addressof(rhs), tmp, sizeof(ValueVariant));
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif
} else {
SlowSwap(lhs, rhs, lhs_trivial, rhs_trivial);
Expand Down