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