Export of internal Abseil changes

--
4c6405d1be98fc669b5167970783da00c6a43b86 by Derek Mauro <dmauro@google.com>:

Turn off -Warray-bounds for GCC in internal/inlined_vector.h
GCC 11 appears to erroneously warn here

PiperOrigin-RevId: 374709739

--
be9909b010b3da5967ab0ff44a09be034a1fa82f by Derek Mauro <dmauro@google.com>:

Add non-templated operator new and new[] to ThrowingValue.
GCC 11 is confused and issues -Wmismatched-new-delete.

PiperOrigin-RevId: 374648084

--
a30a87bf1498aff26bcd751daec120d14a934d99 by Derek Mauro <dmauro@google.com>:

Simplify ThrowingAllocator::select_on_container_copy_construction
to workaround what may be a clang c++20 bug

PiperOrigin-RevId: 374630576
GitOrigin-RevId: 4c6405d1be98fc669b5167970783da00c6a43b86
Change-Id: I48f1091c4a0f262961d9059dac4e6b44a82ae91d
pull/963/head
Abseil Team 4 years ago committed by rogeeff
parent 5de90e2673
commit 7971fb358a
  1. 26
      absl/base/internal/exception_safety_testing.h
  2. 3
      absl/container/internal/inlined_vector.h

@ -536,7 +536,22 @@ class ThrowingValue : private exceptions_internal::TrackedObject {
}
// Memory management operators
// Args.. allows us to overload regular and placement new in one shot
static void* operator new(size_t s) noexcept(
IsSpecified(TypeSpec::kNoThrowNew)) {
if (!IsSpecified(TypeSpec::kNoThrowNew)) {
exceptions_internal::MaybeThrow(ABSL_PRETTY_FUNCTION, true);
}
return ::operator new(s);
}
static void* operator new[](size_t s) noexcept(
IsSpecified(TypeSpec::kNoThrowNew)) {
if (!IsSpecified(TypeSpec::kNoThrowNew)) {
exceptions_internal::MaybeThrow(ABSL_PRETTY_FUNCTION, true);
}
return ::operator new[](s);
}
template <typename... Args>
static void* operator new(size_t s, Args&&... args) noexcept(
IsSpecified(TypeSpec::kNoThrowNew)) {
@ -557,12 +572,6 @@ class ThrowingValue : private exceptions_internal::TrackedObject {
// Abseil doesn't support throwing overloaded operator delete. These are
// provided so a throwing operator-new can clean up after itself.
//
// We provide both regular and templated operator delete because if only the
// templated version is provided as we did with operator new, the compiler has
// no way of knowing which overload of operator delete to call. See
// https://en.cppreference.com/w/cpp/memory/new/operator_delete and
// https://en.cppreference.com/w/cpp/language/delete for the gory details.
void operator delete(void* p) noexcept { ::operator delete(p); }
template <typename... Args>
@ -726,9 +735,8 @@ class ThrowingAllocator : private exceptions_internal::TrackedObject {
ThrowingAllocator select_on_container_copy_construction() noexcept(
IsSpecified(AllocSpec::kNoThrowAllocate)) {
auto& out = *this;
ReadStateAndMaybeThrow(ABSL_PRETTY_FUNCTION);
return out;
return *this;
}
template <typename U>

@ -36,6 +36,7 @@ namespace inlined_vector_internal {
// GCC does not deal very well with the below code
#if !defined(__clang__) && defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
@ -955,7 +956,7 @@ auto Storage<T, N, A>::Swap(Storage* other_storage_ptr) -> void {
swap(*GetAllocPtr(), *other_storage_ptr->GetAllocPtr());
}
// End ignore "maybe-uninitialized"
// End ignore "array-bounds" and "maybe-uninitialized"
#if !defined(__clang__) && defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

Loading…
Cancel
Save