]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix -Warray-bounds warning in std::vector::resize [PR114945]
authorJonathan Wakely <jwakely@redhat.com>
Mon, 31 Mar 2025 11:30:44 +0000 (12:30 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 1 Apr 2025 18:38:33 +0000 (19:38 +0100)
commit844eed3364309bd20cbb7d6793a16b7c6b889ba4
tree437d904bab0e91b641f9a16b74fd7bd5d3816713
parent2fd74c790556a3de6c42efa564781aa2ac0e3596
libstdc++: Fix -Warray-bounds warning in std::vector::resize [PR114945]

This is yet another false positive warning fix. This time the compiler
can't prove that when the vector has sufficient excess capacity to
append new elements, the pointer to the existing storage is not null.

libstdc++-v3/ChangeLog:

PR libstdc++/114945
* include/bits/vector.tcc (vector::_M_default_append): Add
unreachable condition so the compiler knows that _M_finish is
not null.
* testsuite/23_containers/vector/capacity/114945.cc: New test.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
libstdc++-v3/include/bits/vector.tcc
libstdc++-v3/testsuite/23_containers/vector/capacity/114945.cc [new file with mode: 0644]