[Patch] Fix vector wrt __len overflows

Paolo Carlini pcarlini@suse.de
Tue Oct 19 17:15:00 GMT 2004


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.

Paolo.



More information about the Libstdc++ mailing list