This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/46220] New: Error: invalid covariant return type generated for incomplete class type
- From: "nathan.keynes at oracle dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 28 Oct 2010 23:10:46 +0000
- Subject: [Bug c++/46220] New: Error: invalid covariant return type generated for incomplete class type
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: nathan.keynes@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