aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-inline.c
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2018-08-22 23:22:40 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2018-08-22 23:22:40 +0100
commitaf55b3af33f0a35fecd2117a43ee93468925e98c (patch)
tree785f0ac85050c6509f0136d708bdea530a8bc76a /gcc/tree-inline.c
parent2532f0f5e60f7de0a06f3f824f6be618649c216b (diff)
downloadgcc-af55b3af33f0a35fecd2117a43ee93468925e98c.zip
gcc-af55b3af33f0a35fecd2117a43ee93468925e98c.tar.gz
gcc-af55b3af33f0a35fecd2117a43ee93468925e98c.tar.bz2
PR libstdc++/78448 limit vector::max_size and deque::max_size
The container requirements imply that max_size() can't exceed the maximum value of the container's difference_type. Enforce this for std::vector and std::deque, and add checks to ensure the container doesn't grow larger than that. PR libstdc++/78448 * include/bits/deque.tcc (deque::_M_range_initialize): Use _S_check_init_len to check size. (deque::_M_push_back_aux, deque::_M_push_front_aux): Throw length error if size would exceed max_size(). * include/bits/stl_deque.h (_Deque_base::size_type): Remove typedef. (_Deque_base(_Deque_base&&, const allocator_type&, size_t)): Use size_t instead of size_type. (deq(size_type, const allocator_type&) (deq(size_type, const value_type&, const allocator_type&) (deque::_M_initialize_dispatch): Use _S_check_init_len to check size. (deque::max_size): Call _S_max_size. (deque::_S_check_init_len, deque::_S_max_size): New functions. * include/bits/stl_vector.h (vector(size_type, const allocator_type&)) (vector(size_type, const value_type&, const allocator_type&)) (vector::_M_initialize_dispatch, vector::_M_range_initialize): Use _S_check_init_len to check size. (vector::max_size): Call _S_max_size. (vector::_M_check_len): Prevent max from being expanded as a function-like macro. (vector::_S_check_init_len, vector::_S_max_size): New functions. * include/bits/vector.tcc (vector::_M_assign_aux): Use _S_check_init_len to check size. * testsuite/23_containers/deque/capacity/max_size.cc: New test. * testsuite/23_containers/vector/capacity/max_size.cc: New test. From-SVN: r263789
Diffstat (limited to 'gcc/tree-inline.c')
0 files changed, 0 insertions, 0 deletions