C++ allows self initialization.
I understand lines like the following result in j
's value being unspecified or just in undefined behavior:
int j = j;
However, the following self-initialization is fine:
void* myAddr = &myAddr;
My questions are:
As I can't come up with any, can anybody provide an example where a self initialization like the latter may actually be useful?
Is there any other self initialization that doesn't result in undefined behavior nor in the variable's value being unspecified? I.e. is there any other well-behaved self initialization?