This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Construct new elements before moving existing ones, so that if a default constructor throws, the existing elements are not left in a moved-from state. 2018-06-14 Daniel Trebbien <dtrebbien@gmail.com> Jonathan Wakely <jwakely@redhat.com> PR libstdc++/83982 * include/bits/vector.tcc (vector::_M_default_append(size_type)): Default-construct new elements before moving existing ones. * testsuite/23_containers/vector/capacity/resize/strong_guarantee.cc: New. Tested powerpc64le-linux. Daniel (CC'd) originally proposed a fix based on the code used in vector::_M_realloc_insert. This is a slightly simpler fix, possible because resize only inserts at the end not in the middle. I also wrote a new testcase which is also valid in C++98, where the lack of move constructors means the strong exception-safety guarantee is always met. (Which means the bug is a regression since the default mode changed to -std=gnu++14 in GCC 6.1). I plan to commit this to trunk tomorrow, and backport soon too.
Attachment:
patch.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |