]> 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>
Tue, 29 Nov 2022 17:01:32 +0000 (17:01 +0000)
commitcca06f0d6d76b08ed4ddb7667eda93e2e9f2589e
tree3e22e09174f7995e1cb27b3e830aca9e419d170a
parent81cf0354d5f81f2c7600a3bc7ae4600757286995
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.
libstdc++-v3/include/bits/vector.tcc