This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Sizes when sizeof(value_type) == 1 (Was: Re: vector<> can...)
Dhruv Matani wrote:
Consider this line: vector.tcc => 432.
const size_type __len = __old_size + std::max(__old_size, __n);
Well, you see, there is something fishy going on with this kind of
arithmetic,
when sizeof(value_type) == 1. The same happens in other places, also when
__old_size * 2 is simply computed.
With max_size == size_type(-1) in that case, we are everywhere at risk of
overflowing size_type during those computations!
Paolo.
P.S. After all, this morning I was right in spotting something wrong...