This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: typedef name question
Hi Michael,
Not a bug.
The "foo foo;" introduces the foo variable. Once the foo variable is introduced, it shadows (hides) the outer symbol identifier.
If you try to move the "typedef int foo;" inside the function, you'll notice that the "foo foo;" causes a compiler error, because you have the identifer "foo" redeclared in that scope.
You are allowed to introduce identifiers in a scope that shadow identifiers outside that scope. Even in the "foo foo;" case, where you are using an outer scope identifier and in the process are introducing a new identifier that shadows that self-same outer scope identifier.
HTH,
--Eljay