typedefs and elaborated type specifiers

Mark Mitchell mark@codesourcery.com
Thu Jan 20 02:06:00 GMT 2005


Matt Austern wrote:
> Consider the following code sample:
> struct A { };
> typedef struct A A;
> struct A a;                     // [1]
> 
> struct wrapper {
>   struct B { };
>   typedef struct B B;
>   struct B b;                   // [2]
> };

> Where I'm having trouble: why don't we get the same error in [1]?  I've 
> searched in vain for any hint that the two cases should be treated 
> differently.

I haven't searched the standard, but that looks like it should be an 
error to me.  I bet that it's merely an accident of G++'s far-too-many 
different ways of keeping track of declarations; classes are different 
from namespaces...

-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304



More information about the Gcc mailing list