my Q is quite similar to these, but not exactly the same to:
Returning const reference to local variable from a function
Returning function-local variable as reference
I have a bit of code that is used to parse an xml file. what's basically happening is that a local variable is passed by reference OUT of the function using the return statement. To be more precise:
ezxml_t ezxml_parse_fd(int fd){
ezxml_root_t root;
//DO STUFF
return &root->xml;
}
the caller is the following
ezxml_t xml = ezxml_parse_fd(fd);
Well, the thing compiles and works (gcc)... but I have always known that a local variables are destroyed once their scope no longer exists... i'm confused