This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17289] New: covariant returns and recursive templates don't mix
- From: "jens dot maurer at gmx dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Sep 2004 16:17:56 -0000
- Subject: [Bug c++/17289] New: covariant returns and recursive templates don't mix
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This program:
struct Base
{
virtual Base * clone() const = 0;
};
template<class F>
struct D : public Base
{
F * clone() const { return 0; }
};
struct D2 : public D<D2>
{
};
D2 x;
results in this error:
covariant-return-recursive-tmpl.cc: In instantiation of `D<D2>':
covariant-return-recursive-tmpl.cc:13: instantiated from here
covariant-return-recursive-tmpl.cc:9: error: invalid covariant return type for
`F* D<F>::clone() const [with F = D2]'
covariant-return-recursive-tmpl.cc:3: error: overriding `virtual Base*
Base::clone() const'
Since D2 is (indirectly) derived from B, this error seems incorrect.
--
Summary: covariant returns and recursive templates don't mix
Product: gcc
Version: 3.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jens dot maurer at gmx dot net
CC: Jens dot Maurer at is-teledata dot com,gcc-bugs at gcc
dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17289