]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Use RAII to replace try/catch blocks
authorFrançois Dumont <fdumont@gcc.gnu.org>
Thu, 16 May 2024 04:59:50 +0000 (06:59 +0200)
committerFrançois Dumont <frs.dumont@gmail.com>
Wed, 29 May 2024 14:42:50 +0000 (16:42 +0200)
commitd22eaeca7634b57e80ea61cadd82902fdc7e57ea
tree475fca6bc118712c0c78ddd0d26ef1c4b728d821
parentb24b081113c696f4e523c8ae53fc3ab89c3b4e4d
libstdc++: Use RAII to replace try/catch blocks

Move _Guard into std::vector declaration and use it to guard all calls to
vector _M_allocate.

Doing so the compiler has more visibility on what is done with the pointers
and do not raise anymore the -Wfree-nonheap-object warning.

libstdc++-v3/ChangeLog:

* include/bits/vector.tcc (_Guard): Move all the nested duplicated class...
* include/bits/stl_vector.h (_Guard_alloc): ...here and rename.
(_M_allocate_and_copy): Use latter.
(_M_initialize_dispatch): Small code simplification.
(_M_range_initialize): Likewise and set _M_finish first from the result
of __uninitialize_fill_n_a that can throw.
libstdc++-v3/include/bits/stl_vector.h
libstdc++-v3/include/bits/vector.tcc