Paste
Powered by
Mojopaste
//stacktest.c: #include <string.h> #include <stdio.h> #include <stdlib.h> void func(size_t i) { volatile char x[1024*1024]; x[0] = 0; x[sizeof(x)-1] = 0; printf("i=%zu, x=%p, *x=%u\n", i, x, (unsigned)*x); if (i < 1024) func(i + 1); } int main(void) { func(0); return EXIT_SUCCESS; } //ll /* Output: $ ./stacktest i=0, x=0x7ffca3f1c450, *x=0 i=1, x=0x7ffca401c450, *x=0 i=2, x=0x7ffca411c450, *x=0 i=3, x=0x7ffca3c1c430, *x=0 i=4, x=0x7ffca3d1c430, *x=0 i=5, x=0x7ffca3e1c430, *x=0 Segmentation fault */