This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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: 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]