On Saturday, 8 February 2014 at 00:59:35 UTC, Andrei Alexandrescu wrote:

void fun(void* sneaky = alloca(42));

will allocate memory on fun caller's frame and make it available to fun.

I've known this for a while and am not sure whether it's an awesome idiom of the spawn of devil.

Quoting the GNU alloca() man page:

"On many systems alloca() cannot be used inside the list of arguments of a function call, because the stack space reserved by alloca() would appear on the stack in the middle of the space for the function arguments."

So... devil spawn, then?

Reply via email to