https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110498

--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Jonathan Wakely
<r...@gcc.gnu.org>:

https://gcc.gnu.org/g:a5f7850221f935b97980e2a52b1aaeb944d7d1cf

commit r13-9488-ga5f7850221f935b97980e2a52b1aaeb944d7d1cf
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Fri Mar 28 15:41:41 2025 +0000

    libstdc++: Fix -Warray-bounds warning in std::vector<bool> [PR110498]

    In this case, we need to tell the compiler that the current size is not
    larger than the new size so that all the existing elements can be copied
    to the new storage. This avoids bogus warnings about overflowing the new
    storage when the compiler can't tell that that cannot happen.

    We might as well also hoist the loads of begin() and end() before the
    allocation too. All callers will have loaded at least begin() before
    calling _M_reallocate.

    libstdc++-v3/ChangeLog:

            PR libstdc++/110498
            * include/bits/vector.tcc (vector<bool, A>::_M_reallocate):
            Hoist loads of begin() and end() before allocation and use them
            to state an unreachable condition.
            * testsuite/23_containers/vector/bool/capacity/110498.cc: New
            test.

    Reviewed-by: Tomasz KamiÅski <tkami...@redhat.com>

    (cherry picked from commit aa3aaf2bfb8fcc17076993df4297597b68bc5f60)

Reply via email to