summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--absl/container/inlined_vector.h5
-rw-r--r--absl/container/inlined_vector_test.cc1
2 files changed, 4 insertions, 2 deletions
diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h
index bc1c4a77..42121228 100644
--- a/absl/container/inlined_vector.h
+++ b/absl/container/inlined_vector.h
@@ -275,8 +275,9 @@ class InlinedVector {
size_type max_size() const noexcept {
// One bit of the size storage is used to indicate whether the inlined
// vector contains allocated memory. As a result, the maximum size that the
- // inlined vector can express is half of the max for `size_type`.
- return (std::numeric_limits<size_type>::max)() / 2;
+ // inlined vector can express is half of the max for
+ // AllocatorTraits<A>::max_size();
+ return AllocatorTraits<A>::max_size(storage_.GetAllocator()) / 2;
}
// `InlinedVector::capacity()`
diff --git a/absl/container/inlined_vector_test.cc b/absl/container/inlined_vector_test.cc
index 4c1ba04a..0e528113 100644
--- a/absl/container/inlined_vector_test.cc
+++ b/absl/container/inlined_vector_test.cc
@@ -255,6 +255,7 @@ TEST(IntVec, Hardened) {
#if !defined(NDEBUG) || ABSL_OPTION_HARDENED
EXPECT_DEATH_IF_SUPPORTED(v[10], "");
EXPECT_DEATH_IF_SUPPORTED(v[-1], "");
+ EXPECT_DEATH_IF_SUPPORTED(v.resize(v.max_size() + 1), "");
#endif
}