[Bug c++/79095] [7 regression] spurious stringop-overflow warning
law at redhat dot com
gcc-bugzilla@gcc.gnu.org
Sun Jan 22 23:35:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79095
--- Comment #10 from Jeffrey A. Law <law at redhat dot com> ---
So with a prototype patch to simplify the overflow checks to zero/not zero, we
still get the one warning. The more I look at the code, the more I think the
warning is justified.
Ponder the case where v.size () returns 0 in the test. That'll result in
calling v.resize (-1).
In the resize code we have:
resize(size_type __new_size)
{
if (__new_size > size())
_M_default_append(__new_size - size());
else if (__new_size < size())
_M_erase_at_end(this->_M_impl._M_start + __new_size);
}
Remembering that we're working with size_t (ie, unsigned) objects, we'll go
into the TRUE clause, calling:
std::vector<unsigned int>::_M_default_append (&v, 18446744073709551615);
At which point I think we've lost.... And ISTM that GCC gave a valid warning
for the given inputs.
Thoughts Martin?
More information about the Gcc-bugs
mailing list