[Bug c++/46206] New: using typedef-name error with typedef name hiding struct name
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.
[Bug c++/46220] New: Error: invalid covariant return type generated for incomplete class type
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46220 Summary: Error: invalid covariant return type generated for incomplete class type 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++ fails to compile the following test case: class Baz; class Foo { public: virtual const Baz* getBaz() = 0; }; class Bar : public Foo { public: Baz* getBaz(); }; test-covar.cc:8: error: invalid covariant return type for ‘virtual Baz* Bar::getBaz()’ test-covar.cc:4: error: overriding ‘virtual const Baz* Foo::getBaz()’ However, it compiles successfully if Baz is complete: class Baz { }; class Foo { public: virtual const Baz* getBaz() = 0; }; class Bar : public Foo { public: Baz* getBaz(); }; 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). Works correctly with g++ 3.4.3