public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17289] New: covariant returns and recursive templates don't mix
@ 2004-09-02 16:17 jens dot maurer at gmx dot net
2004-09-02 16:24 ` [Bug c++/17289] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: jens dot maurer at gmx dot net @ 2004-09-02 16:17 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/17289] covariant returns and recursive templates don't mix
2004-09-02 16:17 [Bug c++/17289] New: covariant returns and recursive templates don't mix jens dot maurer at gmx dot net
@ 2004-09-02 16:24 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-02 16:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-09-02 16:24 -------
Actually the error is correct.
Class D2 is not finished when you the template D<D2> is instantiated so we (the compiler) don't know
that D2 is a derived class of Base.
Here is the error which ICC gives:
pr17289.cc(10): error: return type is not identical to nor covariant with return type "Base *" of
overridden virtual function function "Base::clone"
F * clone() const { return 0; }
^
detected during instantiation of class "D<F> [with F=D2]" at line 13
pr17289.cc(17): error: object of abstract class type "D2" is not allowed:
pure virtual function "Base::clone" has no overrider
D2 x;
^
compilation aborted for pr17289.cc (code 2)
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17289
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-09-02 16:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-02 16:17 [Bug c++/17289] New: covariant returns and recursive templates don't mix jens dot maurer at gmx dot net
2004-09-02 16:24 ` [Bug c++/17289] " pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).