This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Sizes when sizeof(value_type) == 1 (Was: Re: vector<> can...)


Dhruv Matani wrote:

I don;t think so. It seems fine to me.

Let's consider just a series of push_back: every time you reallocate,
the size doubles (in _M_insert_aux), and this gives problems as soon
as you reach ~ half max_size.

Ok, a simple example with an hypothetical 16-bit machine: in this case,
max_size = 65535 (we are always working with sizeof(vale_type) == 1).

When __old_size = 32768, _M_insert_aux computes __old_size * 2, which
is *exactly zero*, since overflows the max rapresentable number by one!

You could easily ask the allocator whatever in the range [__old_size + 1,
2 * __old_size - 1], and instead you are asking exactly zero!

Stra-bummer!

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]