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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 08 Nov 2014 20:30:44 +0200

> Date: Sat, 8 Nov 2014 19:17:55 +0100
> From: Alexander Shukaev <[email-masked]>
> Cc: [email-masked]
> 
> I've got something amazing/phenomenal here. Read carefully. With "-g -O0" it
> can reserve memory just fine and everything builds successfully. With "-O3" it
> fails with the first try, i.e. with the size of 0x68000000 and the
> corresponding error is:
> 
>     ERROR_NOT_ENOUGH_MEMORY
>     8 (0x8)
>     Not enough storage is available to process this command.
> 
> Since with "-g -O0" it succeeds, it cannot be debugged with GDB. For "-O3" I
> used simple `printf' testing.
> 
> I can test "-O2" if you are interested.

Yes, please do.  I don't think I ever tried -O3 (and I don't think
it's a good idea in Emacs in general).

> What does it smell like? A toolchain bug?

Could be.  What GCC version are you using?

Also, when -O3 is used, does it help to declare reserved_heap_size
volatile, like this:

  size_t volatile reserved_heap_size;

(You might need to change the extern declaration on w32heap.h as
well.)