This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [PR19351, C++] Fix heap overflow in operator new[]


On Sun, 6 Feb 2011, Richard Guenther wrote:

> I haven't yet looked at the code this check generates for the middle-end,
> but does it consider targets like m32c where addresses are 24bit
> but for example sizetype (and size_t?) is 16bit because m32c cannot do
> arithmetic in
> the larger mode?  I wonder if the code the FE presents us with is 1) correct,
> 2) results in absymal code on such targets.

The saturation certainly needs to be in type size_t; it's not meaningfully 
possible to have objects larger than that.  (In fact it's not safely 
possible to have objects larger than PTRDIFF_MAX bytes either, which is 
usually the same value as SIZE_MAX >> 1, as subtraction of pointers to 
elements of larger objects may not work reliably.  Thus C malloc should be 
rejecting allocations between PTRDIFF_MAX and SIZE_MAX, even if enough 
memory is available for them.)

-- 
Joseph S. Myers
joseph@codesourcery.com


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