]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Avoid bogus warning in std::vector::insert [PR107852]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 29 Nov 2022 15:50:06 +0000 (15:50 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 20 Apr 2023 11:27:02 +0000 (12:27 +0100)
commit2e4210698c644e44f9e0645dc7bc49710fd60ce8
treec79eb9e144d0c06bfbfc245db18b0679cc68e12b
parente016a6ddbf0038056b9d8f2bc0bad350ff026632
libstdc++: Avoid bogus warning in std::vector::insert [PR107852]

GCC assumes that any global variable might be modified by operator new,
and so in the testcase for this PR all data members get reloaded after
allocating new storage. By making local copies of the _M_start and
_M_finish members we avoid that, and then the compiler has enough info
to remove the dead branches that trigger bogus -Warray-bounds warnings.

libstdc++-v3/ChangeLog:

PR libstdc++/107852
PR libstdc++/106199
PR libstdc++/100366
* include/bits/vector.tcc (vector::_M_fill_insert): Copy
_M_start and _M_finish members before allocating.
(vector::_M_default_append): Likewise.
(vector::_M_range_insert): Likewise.

(cherry picked from commit cca06f0d6d76b08ed4ddb7667eda93e2e9f2589e)
libstdc++-v3/include/bits/vector.tcc