This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Integer overflow in operator new
On 09 April 2007 21:49, Lawrence Crowl wrote:
>>> The optimization above would be wrong for such machines because
>>> the allocation would be smaller than the requested size.
>>
>> To request a size of ~size_t(0) is to request a size
>> of 0xFFFFFFFF or 0xFFFFFFFFFFFFFFFFULL that the allocator
>> will always "sorry, there is not memory of 0xFFFFFFFF or
>> 0xFFFFFFFFFFFFFFFFULL bytes.
>
> Except on a segmented machine, where it will say "here you go!"
> On segmented architectures sizeof(size_t) < sizeof(void*).
Well, we could simply use uintptr_t instead of size_t.
cheers,
DaveK
--
Can't think of a witty .sigline today....