So you may be asking: "What the heck is a dynamic stack allocation?"
This is what I mean:
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
// this is, I presume, a dynamic stack allocation
char echoback[strlen(argv[0]) + 1];
memset(echoback, 0, sizeof(echoback));
memcpy(echoback, argv[0], strlen(argv[0]));
printf("%s\n", echoback);
return 0;
}
I added the comment "// this is, I presume, a dynamic stack allocation" because I'm actually not sure what assembly code gcc is producing for this. I am not sure if gcc is entirely using stack space for 'echoback' or not.
Presuming that gcc IS putting 'echoback' entirely in stack space, I would call this a "dynamic stack allocation," and my question is, if this is what is happening, is there a gcc command line option to disable this such that a compiler error or warning is produced at compile-time?
i.e., is there something line -fdisable-dynamic-stack or -Wdynamic-stack?