]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix vector(from_range_t, R&&) for exceptions [PR120367]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 21 May 2025 14:29:02 +0000 (15:29 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 22 May 2025 11:11:43 +0000 (12:11 +0100)
commit04f2be72b1deecd6c6d454e000cfc0cb16db957c
tree7f072daeca98a98f63b233a087fca7c63af97b5a
parent63cd56d487bdea70bf30fb0db8cd4f755338d54b
libstdc++: Fix vector(from_range_t, R&&) for exceptions [PR120367]

Because this constructor delegates to vector(a) the object has been
fully constructed and the destructor will run if an exception happens.
That means we need to set _M_finish == _M_start so that the destructor
doesn't try to destroy any elements.

libstdc++-v3/ChangeLog:

PR libstdc++/120367
* include/bits/stl_vector.h (_M_range_initialize): Initialize
_M_impl._M_finish.
* testsuite/23_containers/vector/cons/from_range.cc: Check with
a type that throws on construction.
exceptions during construction.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
libstdc++-v3/include/bits/stl_vector.h
libstdc++-v3/testsuite/23_containers/vector/cons/from_range.cc