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]

no rtti polymorphism


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

polyinh.C

Makefile


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