bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: checked integer arithmetic


From: Bruno Haible
Subject: Re: checked integer arithmetic
Date: Thu, 15 Dec 2016 03:17:29 +0100
User-agent: KMail/4.8.5 (Linux/3.8.0-44-generic; KDE/4.8.5; x86_64; ; )

Paul Eggert wrote:
> Come to think of it, I suppose we should change xalloc_oversized to 
> report an overflow if the resulting size would be greater than 
> PTRDIFF_MAX. That should catch more potential problems in Gnulib and in 
> Gnulib-using code.
> ...
> Here is an example of why arrays larger than PTRDIFF_MAX bytes can cause 
> real problems.

So, an attempt to allocate a memory chunk of 2.5 GB size on 32-bit Linux/x86
is ill-fated already? That is, SIZE_MAX = 4 GB - 1 gives us a fake illusion
that allocations > 2 GB would be OK, and in fact they are not OK, so it's
in fact ssize_t or ptrdiff_t that matters?!

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]