diff --git a/abseil-cpp.spec b/abseil-cpp.spec index 0617216351f..dcdde6e4925 100644 --- a/abseil-cpp.spec +++ b/abseil-cpp.spec @@ -2,10 +2,12 @@ ## INCLUDE cpp-standard Source: https://github.com/abseil/abseil-cpp/archive/%{realversion}.tar.gz +Patch0: patches/abseil-cpp-ubsan BuildRequires: cmake gmake %prep %setup -n %{n}-%{realversion} +%patch0 -p1 %build rm -rf ../build diff --git a/patches/abseil-cpp-ubsan.patch b/patches/abseil-cpp-ubsan.patch new file mode 100644 index 00000000000..cb250a22fb9 --- /dev/null +++ b/patches/abseil-cpp-ubsan.patch @@ -0,0 +1,44 @@ +diff --git a/absl/container/internal/hash_policy_traits.h b/absl/container/internal/hash_policy_traits.h +index e469d71..6c6627b 100644 +--- a/absl/container/internal/hash_policy_traits.h ++++ b/absl/container/internal/hash_policy_traits.h +@@ -28,6 +28,16 @@ + namespace absl { + ABSL_NAMESPACE_BEGIN + namespace container_internal { ++// Selects the policy-provided type-erased hash-slot function, or the generic ++// non-type-erased fallback when the policy returns nullptr. ++template ++struct HashSlotFnSelector { ++ static constexpr HashSlotFn kValue = kPolicyFn; ++}; ++template ++struct HashSlotFnSelector { ++ static constexpr HashSlotFn kValue = kFallbackFn; ++}; + + // Defines how slots are initialized/destroyed/moved. + template +@@ -148,19 +158,9 @@ template + + template + static constexpr HashSlotFn get_hash_slot_fn() { +-// get_hash_slot_fn may return nullptr to signal that non type erased function +-// should be used. GCC warns against comparing function address with nullptr. +-#if defined(__GNUC__) && !defined(__clang__) +-#pragma GCC diagnostic push +-// silent error: the address of * will never be NULL [-Werror=address] +-#pragma GCC diagnostic ignored "-Waddress" +-#endif +- return Policy::template get_hash_slot_fn() == nullptr +- ? &hash_slot_fn_non_type_erased +- : Policy::template get_hash_slot_fn(); +-#if defined(__GNUC__) && !defined(__clang__) +-#pragma GCC diagnostic pop +-#endif ++ return HashSlotFnSelector< ++ &hash_slot_fn_non_type_erased, ++ Policy::template get_hash_slot_fn()>::kValue; + } + + // Whether small object optimization is enabled. True by default.