According to one of my books,the following code should not work:
void f(){
int ma;
cin >> ma;
if(ma == 10)
goto heya;
int x;
heya:
cout << "a";
}
Why? Because the storage for x is allocated at the beginning of the code block,but if I type 10,then it will jump to heya,so,it will skip the definition,thus constructor call.
The code should generate a warning,or an error,but I got none.
The code + explanation is from Thinking in C++.
Is that concept still correct,or outdated?