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

From: Eli Zaretskii <[email-masked]>
Date: Sun, 09 Nov 2014 18:47:00 +0200

> From: Andreas Schwab <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Sun, 09 Nov 2014 17:30:21 +0100
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > Given that, it is justified for GCC to give us what we deserve, i.e. a
> > loop "unrolled" by executing its body only once.  I present the
> > disassembly below, for the curious, and it's clear that there's no
> > loop there, and also the value of 'size' is never tested at all, since
> > GCC decided that the condition 'size > 0x00100000' is always true.
> 
> But if you replace 'size > 0x00100000' with true, you get a loop that is
> conditionalized by '!ptr', which depends on the execution of the loop
> body.  Why would it be correct to execute the loop only once,
> unconditionally?

Feel free to report this as a GCC bug, if you think that's what it is.
All I can tell is that the same behavior is present in 3 different GCC
releases from 3 different major versions.

In any case, I think the original code had a subtle bug, in that the
comparison of 'size' didn't do what the author intended.