[Patch] Fix vector wrt __len overflows

Dhruv Matani dhruvbird@gmx.net
Tue Oct 19 17:27:00 GMT 2004


On Tue, 2004-10-19 at 22:44, Paolo Carlini wrote:
> Nathan Myers wrote:
> 
> >Shouldn't we just try to allocate as much as we can, instead?
> >
> >That hypothetical 16-bit machine might have 32-bit addresses and 
> >be able to allocate a full 64K for each vector.
> >
> Well, if you really think we support such machines... ;)
> Then the condition would become:
> 
>     if (__len < __old_size)
>        __len = size_type(-1);
> 
> and the allocator will throw bad_alloc, in case... Ok, makes sense.

But even then, size_type(-1) is < The required size. Or is it?

> 
> Paolo.
-- 
        -Dhruv Matani.
http://www.geocities.com/dhruvbird/

The price of freedom is responsibility, but it's a bargain, because
freedom is priceless. ~ Hugh Downs



More information about the Libstdc++ mailing list