Xref: utzoo comp.sys.sgi:8766 comp.lang.c++:12172 Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!uunet!contex!jeff From: jeff@contex.UUCP (Jeff Carey) Newsgroups: comp.sys.sgi,comp.lang.c++ Subject: SGI C++ 2.0 Polymorphic Reference Bug Keywords: SGI PI C++ 2.0 polymophism reference bug Message-ID: <1688@contex.UUCP> Date: 12 Mar 91 16:02:07 GMT Followup-To: comp.sys.sgi Organization: Xyvision Design Systems, Wakefield MA Lines: 58 I am using: System release: IRIX Release 4D1-3.3.1 C++ release: S4-C++-2.0 Software Option: C++ Translator Version 2.0 on a Silicon Graphics PI. The other day I was testing the code found in the discussion of "Virtual Base Classes with Virtual Functions", section 10.10c, pp. 233-4, of _The_Annotated_C++_Reference_Manual_ and found the following bug. You'll notice that the bug is in the call made to f() from the MW object reference (MW&). ---------------------- beginning of test.c++ code ---------------------------- #include class W { public: virtual void f() { cout << "W::f\n"; } }; class MW : public virtual W {}; class BW : public virtual W { public: void f() { cout << "BW::f\n"; } }; class BMW : public BW, public MW {}; main() { BMW bmw; MW* pmw = &bmw; pmw->f(); MW& rmw = bmw; rmw.f(); return(0); } ----------------------------- end of test code ------------------------------- I got this result: $ test BW::f W::f I would have predicted and hoped that the two lines of diagnostics would result in the same text. This is a bug isn't it...polymorphism of this sort should be supported by references as well as pointers, right?! Ouch --- jeff -- ------------------------ Jeff Carey contex!jeff@uunet.uu.net