no rtti polymorphism

Frank Joppe frankj@delta-n.com
Fri Jun 16 01:18:00 GMT 2000


Hi, I've encountered the following in all egcs 
versions I've used. I'm not sure whether this should be regarded as a bug, but 
it feels like it does. I've attached reproducing source code in polyinh.C, the 
makefile and the testresults.
 
One of the first things I learned about C++ OO 
properties was that I would not have to use 'while' or 'switch / case' 
constructions anymore, this is why I feel like I'm reporting a bug.
 
class A
{
  virtual void foo( const A & par 
)
  {
    // report 
incompatible
  }
}
 
class B : public A
{
  virtual void foo( const B & par 
)
  {
    // report 
compatible
  }
}
 
With these two classes any combination of 
B::foo( x ) should be incompatible for any x not of type B. It should be 
compatible with x being of type B.
 
Running the program tells us that calling 'foo' is 
incompatible in any case. I've also tried a polymorphic variant where all 
polymorphic methods also exist in class B, this gives us the same 
result.
 
Current work-around I've used is to dynamic cast a 
pointer ( for foo( const A *par) ) and check whether it returns 
NULL.
 
Could you give me your opinion on 
this?
 
Thanks
    Frank Joppe
 
 
 
not compatible
not compatible
not compatible
not compatible
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: text/x-makefile
Size: 171 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20000616/527fd85d/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: polyinh.C
Type: text/x-c++
Size: 784 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20000616/527fd85d/attachment-0001.bin>


More information about the Gcc-bugs mailing list