http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46206
Summary: using typedef-name error with typedef name hiding struct name Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: nathan.key...@oracle.com G++ rejects the following code: class Foo { bool a, b, c, d; typedef struct Bar { } Bar; virtual void foo(void) { struct Bar bar; } }; example.cc: In member function ‘virtual void Foo::foo()’: example.cc:6: error: using typedef-name ‘Foo::Bar’ after ‘struct’ example.cc:4: error: ‘Foo::Bar’ has a previous declaration here example.cc:6: error: invalid type in declaration before ‘;’ token but accepts many similar examples, including: class Foo { bool a, b, c; typedef struct Bar { } Bar; virtual void foo(void) { struct Bar bar; } }; This behaviour is reproducible on x86_64-redhat-linux (4.1.2 and 4.4.0) and i386-pc-solaris2.11 (4.2.4, 4.3.4 and 4.5.1) I'm uncertain if this is strictly legal or not per the standard, but it doesn't seem to make sense to accept one of these cases but not the other.