public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/24893] New: inherited polymorphic template class
@ 2005-11-16 15:08 fmaerten at igeoss dot com
2005-11-16 15:17 ` [Bug c++/24893] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: fmaerten at igeoss dot com @ 2005-11-16 15:08 UTC (permalink / raw)
To: gcc-bugs
Hi all,
We just found a bug while compiling the following code. The derived template
class doens't know the pure virtual method from its parent class when this
template class has a method with the same name, but with different arguments:
class A {
public:
virtual void doit() = 0 ;
} ;
template <typename T>
class B: public A {
public:
virtual void doit(double) {}
} ;
class C: public B<double> {
public:
virtual void doit() {}
} ;
int main() {
A* a = new C ;
B<double>* b = new C ;
a->doit() ; // ok
// Compile error with gcc-3.4.3:
// error: no matching function for call to `B<double>::doit()'
// note: candidates are: void B<T>::doit(double) [with T = double]
b->doit() ;
}
--
Summary: inherited polymorphic template class
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fmaerten at igeoss dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24893
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/24893] inherited polymorphic template class
2005-11-16 15:08 [Bug c++/24893] New: inherited polymorphic template class fmaerten at igeoss dot com
@ 2005-11-16 15:17 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-16 15:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2005-11-16 15:17 -------
First this has nothing to do with templates, you can reproduce the error
message without templates.
Second this is how C++ works.
doit(double) in B<T> hides doit(void) in A as it is the same name.
The way to fix it would either to do:
b->A::doit() ;
or:
Change defintion of B to include a using statement like:
template <typename T>
class B: public A {
public:
virtual void doit(double) {}
using A::doit;
} ;
This makes both doit visible in B<T>. In fact you will have the same issue
trying to call doit(double) in C, you solve it the same way.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24893
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-11-16 15:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-16 15:08 [Bug c++/24893] New: inherited polymorphic template class fmaerten at igeoss dot com
2005-11-16 15:17 ` [Bug c++/24893] " 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).