aboutsummaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2020-06-17 22:49:06 +0100
committerJonathan Wakely <jwakely@redhat.com>2020-06-17 22:49:06 +0100
commit632183ddcc8f3aead8b4fc63c4ab59a42ef9ad00 (patch)
treeddcacb50ebec5eaf0359ac2b8fb250d934f467ab /libgcc
parent973bce0fb50bbfd91f47238b82b99935525716ad (diff)
downloadgcc-632183ddcc8f3aead8b4fc63c4ab59a42ef9ad00.zip
gcc-632183ddcc8f3aead8b4fc63c4ab59a42ef9ad00.tar.gz
gcc-632183ddcc8f3aead8b4fc63c4ab59a42ef9ad00.tar.bz2
libstdc++: Avoid stack overflow in std::vector (PR 94540)
The std::__uninitialized_default_n algorithm used by std::vector creates an initial object as a local variable then copies that into the destination range. If the object is too large for the stack this crashes. We should create the first object directly into the destination and then copy it from there. This doesn't fix the bug for C++98, because in that case the initial value is created as a default argument of the vector constructor i.e. in the user's code, not inside libstdc++. We can't prevent that. PR libstdc++/94540 * include/bits/stl_uninitialized.h (__uninitialized_default_1<true>): Construct the first value at *__first instead of on the stack. (__uninitialized_default_n_1<true>): Likewise. Improve comments on several of the non-standard algorithms. * testsuite/20_util/specialized_algorithms/uninitialized_default/94540.cc: New test. * testsuite/20_util/specialized_algorithms/uninitialized_default_n/94540.cc: New test. * testsuite/20_util/specialized_algorithms/uninitialized_value_construct/94540.cc: New test. * testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/94540.cc: New test. * testsuite/23_containers/vector/cons/94540.cc: New test.
Diffstat (limited to 'libgcc')
0 files changed, 0 insertions, 0 deletions