In the first example, as you noticed, the behavior is undefined, although the syntax is fine. Therefore, the compiler is allowed to abandon the code (undefined behavior must be guaranteed, but it is here, but this does not mean that invalid initializations were never actually performed).
In your second example, there is an error like: an ad is displayed as soon as its declarator is viewed, and, in particular, it is displayed in its own initializer. MSVC ++ delays visibility: this is a known mismatch problem in this compiler. For example, with the EDG compiler (which has Microsoft mode):
$ ./cfe --strict xc "xc", line 4: error: a value of type "int **" cannot be used to initialize an entity of type "int *" { int *i(&i); } ^ 1 error detected in the compilation of "xc". $ ./cfe --microsoft xc "xc", line 4: warning: variable "i" was declared but never referenced { int *i(&i); } ^
user1056575
source share