The gcc compiler by protects the stack if the option stack-protector is on.
This option can be turned on by using the option:
gcc -fstack-protector prog.c -o prog
The compiler is typically installed with this option being the default.
It can be turned off by using the option:
-fno-stack-protector Example: gcc -fno-stack-protector prog.c -o prog