Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions abseil-cpp.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 44 additions & 0 deletions patches/abseil-cpp-ubsan.patch
Original file line number Diff line number Diff line change
@@ -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 <HashSlotFn kFallbackFn, HashSlotFn kPolicyFn>
+struct HashSlotFnSelector {
+ static constexpr HashSlotFn kValue = kPolicyFn;
+};
+template <HashSlotFn kFallbackFn>
+struct HashSlotFnSelector<kFallbackFn, nullptr> {
+ static constexpr HashSlotFn kValue = kFallbackFn;
+};

// Defines how slots are initialized/destroyed/moved.
template <class Policy, class = void>
@@ -148,19 +158,9 @@ template <class Policy, class = void>

template <class Hash, bool kIsDefault>
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<Hash, kIsDefault>() == nullptr
- ? &hash_slot_fn_non_type_erased<Hash, kIsDefault>
- : Policy::template get_hash_slot_fn<Hash, kIsDefault>();
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
+ return HashSlotFnSelector<
+ &hash_slot_fn_non_type_erased<Hash, kIsDefault>,
+ Policy::template get_hash_slot_fn<Hash, kIsDefault>()>::kValue;
}

// Whether small object optimization is enabled. True by default.