]> 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>
Wed, 2 Apr 2025 08:55:45 +0000 (09:55 +0100)
commit6b11aed73f6601de32082a4519022d4de1ce8a8f
treed7b3abae83a6f8188ffc48a38f0479d4ad998b1a
parentc839965c2ef689cfd62c4ddeb61d872c0d04366c
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>
(cherry picked from commit 844eed3364309bd20cbb7d6793a16b7c6b889ba4)
libstdc++-v3/include/bits/vector.tcc
libstdc++-v3/testsuite/23_containers/vector/capacity/114945.cc [new file with mode: 0644]