I believe that technically speaking it is not valid, however I do not know what section
of the standard talks about pointers to invalid memory locations. (However I was
told by a friend who knows the standard far better than me that it is invalid).
You're returning the address of a variable on the stack. When the function exits the variable will no longer be valid and the memory may be reused by something else.
The syntax is correct although you should use reinterpret_cast, but it doesn't make much sense.
well no, it's not returning an address, just sticking an int into the space of a void pointer.
so there are issues,
this code will compile on my old laptop but on my AMD64 I get: error: cast from 'void*' to 'int' loses precision
but if I make it long it will compile
I am back from the secret RHL lab.....as of now this is not recommended.... the local variable gets destroyed on return. So you need to hit the heap.
Traditionally i guess the values get copied back. I tried the same with a structure with a const/dest defined. Turns out , the destructor is called ....and the object references are hay-wire......
I'll get back to the lab and try out some more stuff!