Subject: bug#18995: Error: Could not reserve dynamic heap area.

From: Eli Zaretskii <[email-masked]>
Date: Sun, 09 Nov 2014 19:14:58 +0200

> From: Andreas Schwab <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Sun, 09 Nov 2014 17:35:30 +0100
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > It looked like a GCC bug at first, but as I tried to modify the source
> > and look at the effect of that on the generated code, it finally
> > dawned on me: GCC's loop-unrolling code simply correctly calculated
> > that with the initial value of 0x68000000 and decrement of 0x00800000,
> > the value of 'size' in the loop will never be less than 0x00100000,
> > due to wraparound in the subtraction of unsigned values.
> 
> Before wraping around, size will become zero, which is definitely less
> than 0x00100000.

Right, so it could be pure GCC bug after all.

For the record, the problem also goes away if 'size' is declared
ptrdiff_t, and nothing else is changed.  So whatever the reason, it
definitely is somehow related to unsigned arithmetics.