diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2018-10-10 16:39:33 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2018-10-10 16:39:33 +0100 |
commit | 422a9f77892599ecf8e498d0e5e32b1db3cab559 (patch) | |
tree | 793ea99effcef869eeff038bf4f2893773e0b797 /gcc | |
parent | d3a46ecb386b46dfc8e01a2f50c77804e484c4c5 (diff) | |
download | gcc-422a9f77892599ecf8e498d0e5e32b1db3cab559.zip gcc-422a9f77892599ecf8e498d0e5e32b1db3cab559.tar.gz gcc-422a9f77892599ecf8e498d0e5e32b1db3cab559.tar.bz2 |
PR libstdc++/87544 limit max_size() to PTRDIFF_MAX / sizeof(T)
The C++17 standard requires the default implementation for
allocator_traits::max_size to return SIZE_MAX / sizeof(value_type).
That causes GCC to warn because the value could be larger than can
sensibly be passed to malloc. This patch changes the new_allocator and
malloc_allocator max_size() members to use PTRDIFF_MAX instead of
SIZE_MAX (and because they define it, the allocator_traits default isn't
used). This also changes vector::max_size to impose a sensible limit
using PTRDIFF_MAX for cases where the value from the allocator or
allocator_traits is not sensible.
PR libstdc++/87544
* include/bits/stl_vector.h (vector::_S_max_size): Limit size to
PTRDIFF_MAX / sizeof(value_type).
* include/ext/malloc_allocator.h (malloc_allocator::max_size):
Likewise.
* include/ext/new_allocator.h (new_allocator::max_size): Likewise.
* testsuite/23_containers/vector/allocator/minimal.cc: Adjust
expected value for max_size().
* testsuite/23_containers/vector/capacity/87544.cc: New test.
From-SVN: r265021
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions