diff options
author | Abseil Team <absl-team@google.com> | 2021-05-19 12:55:13 -0700 |
---|---|---|
committer | rogeeff <rogeeff@google.com> | 2021-05-19 22:59:16 -0400 |
commit | 7971fb358ae376e016d2d4fc9327aad95659b25e (patch) | |
tree | 18df41552ce212917fd049bf2f7e75125f56043a /absl | |
parent | 5de90e2673bd0c19de67c68e2fe543444dc1114a (diff) |
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
Diffstat (limited to 'absl')
-rw-r--r-- | absl/base/internal/exception_safety_testing.h | 26 | ||||
-rw-r--r-- | absl/container/internal/inlined_vector.h | 3 |
2 files changed, 19 insertions, 10 deletions
diff --git a/absl/base/internal/exception_safety_testing.h b/absl/base/internal/exception_safety_testing.h index 6ba89d05..77a5aec6 100644 --- a/absl/base/internal/exception_safety_testing.h +++ b/absl/base/internal/exception_safety_testing.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> diff --git a/absl/container/internal/inlined_vector.h b/absl/container/internal/inlined_vector.h index b8aec45b..49822af0 100644 --- a/absl/container/internal/inlined_vector.h +++ b/absl/container/internal/inlined_vector.h @@ -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 |