#include <stdio.h>
void func(int **z)
{
int q = 10; /* Local variable */
*z = &q;
}
int main()
{
int a = 100;
int *p = &a;
printf("%d\n", *p);
func(&p);
/* dereferencing pointer with func() local variable 'q' address */
printf("%d\n", *p);
getchar();
printf("exit");
}
In the above code local variable is accessed in main() even though stack for local variable is collapsed. I was expecting a Core Dump/Segmentation fault. But it not happening in this scenario.