Sizes when sizeof(value_type) == 1 (Was: Re: vector<> can...)
Paolo Carlini
pcarlini@suse.de
Mon Oct 18 19:36:00 GMT 2004
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...
More information about the Libstdc++
mailing list