[PATCH] Fix -Wstringop-overflow warning in 23_containers/vector/types/1.cc PR109849
Jonathan Wakely
jwakely@redhat.com
Mon Jun 3 16:20:31 GMT 2024
On Mon, 3 Jun 2024 at 05:56, François Dumont <frs.dumont@gmail.com> wrote:
>
> I hadn't try to make my patch as limited as possible to fix the problem,
> indeed.
>
> libstdc++: Fix -Wstringop-overflow warning coming from std::vector
> [PR109849]
>
> libstdc++-v3/ChangeLog:
>
> PR libstdc++/109849
> * include/bits/vector.tcc
> (std::vector<>::_M_range_insert(iterator, _FwdIt, _FwdIt,
> forward_iterator_tag)): Add __builtin_unreachable
> expression to tell
> the compiler that the allocated buffer is large enough to
> receive current
> elements plus the range to insert.
>
> Tested under Linux x64, ok to commit ?
Does the !__builtin_constant_p(__len) in this version do anything?
If it's a constant, then the compiler can already provide it's in
range, so the __builtin_unreachable() is redundant, but doesn't do any
harm.
More information about the Libstdc++
mailing list