If I have the following:
int *test()
{
    int d = 10;
    int a[d];
    a[0] = 10;
    a[1] = 20;
    printf("%p\n", a);
    return a;
}
int main(void)
{
    int *a = test();
    printf("%p %d\n", a, a[0]);
    return 0;
} 
when I return a from test to main the memory allocated for a inside test is not
destroyed. But why? Isn't a an automatic storage variable that die when the block
function exit? In fact when I compile the code the compiler warn me with:
function returns address of local variable [-Wreturn-local-addr]
The same thing happen if I use a static array.
 
     
     
    