by version_five · 3y ago · 0 comments
int * bar() {
int d[2] = {1,2};
return d;}
When you compile with gcc you get foo.c: In function ‘bar’:
foo.c:4:8: warning: function returns address of local variable [-Wreturn-local-addr]
This is the behavior it seems like you were expecting, where the array is stored on the stack and so a pointer is invalid once the function ends.No comments yet.