I notice that the following code compiles with recent compilers:
int main()
{
int x;
struct x;
x = 210; // ←
}
As I recall it didn't compile some years ago.
Were the lookup rules changed in C++11 or C++14 to make this code “work” (thus breaking use of struct variable_name; as a means to ensure no use of the variable in the following code)?
Update:
Evidently I remembered incorrectly. I have verified that the code compiled OK even with Visual C++ 2010. However, when used for parameters the struct name is in an inner scope, and shadows, like in this code:
void foo( int x )
{
struct x;
x = 210; // ← Error
}
int main()
{
}
Accordingly I have selected as “solution” the answer that there was no change; the rules were always like this.