[fpc-pascal] alloca
Marco van de Voort
fpc at pascalprogramming.org
Sat May 14 17:31:09 CEST 2022
On 14-5-2022 10:49, Hairy Pixels via fpc-pascal wrote:
> Apparently what it does is advance the stack pointer x bytes and return a pointer to the new location so you could probably do that with some assembly. Of course this is dangerous because you can request more memory than exists in the current frame.
But optimizations sometimes eliminate the frame pointer and use the
stackpointer directly to index e.g. local vars and params. Also when an
exception happens, the stack pointer is not as expected in exception
frames (don't know if that really is an issue, but I can image). It
would be interesting how C handles this (e.g. exceptions while alloca
called in a loop?)
So the only non hacky way is to implement support in the compiler I think.
More information about the fpc-pascal
mailing list