home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / g / bug / 2110 < prev    next >
Encoding:
Text File  |  1993-01-02  |  1.7 KB  |  93 lines

  1. Newsgroups: gnu.g++.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!dtro.e-technik.TH-darmstadt.DE!mnl
  3. From: mnl@dtro.e-technik.TH-darmstadt.DE (Michael N. Lipp)
  4. Subject: virtual function resolution bug in gcc-2.3.3
  5. Message-ID: <MNL.93Jan2161553@mnlsun.dtro.e-technik.th-darmstadt.de>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: TH-Darmstadt
  8. Distribution: gnu
  9. Date: Sat, 2 Jan 1993 16:15:53 GMT
  10. Approved: bug-g++@prep.ai.mit.edu
  11. Lines: 80
  12.  
  13. Compiling this program (using gcc-2.3.3 and Sparc/SunOS or
  14. PC/Linux) results in the faulty output "M::F1". If you remove F1 and
  15. F2 from class M (or declare GetC as first method) you get the correct
  16. output T::GetC.
  17.  
  18. --------------------------------------------------
  19. // -*- c++ -*-
  20. #include <iostream.h>
  21.  
  22. class C
  23. {
  24. public:
  25.   int i;
  26. };
  27.  
  28.  
  29. class M
  30. {
  31. private:
  32.   C* c;
  33.  
  34. public:
  35.   virtual void F1 ();
  36.   virtual void F2 ();
  37.   virtual C* GetC () = 0;
  38. };
  39.  
  40. void M::F1 ()
  41. {
  42.   cout << "M::F1\n";
  43. }
  44.  
  45. void M::F2 ()
  46. {
  47.   cout << "M::F2\n";
  48. }
  49.  
  50. class F
  51. {
  52. private:
  53.   C* c;
  54.  
  55. public:
  56.   virtual C* GetC () = 0;
  57. };
  58.  
  59. class T : public M, public F
  60. {
  61. private:
  62.   C* c;
  63.  
  64. public:
  65.   virtual C* GetC ();
  66. };
  67.  
  68. C* T::GetC ()
  69. {
  70.   cout << "T::GetC\n";
  71.   return c;
  72. }
  73.  
  74.  
  75. main ()
  76. {
  77.   T o;
  78.   T* op = &o;
  79.   op->GetC ();
  80. }
  81. --------------------------------------------------
  82.  
  83. Michael
  84.  
  85. --
  86. -----------------,------------------------------,------------------------------
  87. Michael N. Lipp  !  Institut fuer Datentechnik  !  Phone: 49-6151-163776
  88.                  !  Merckstr. 25     ,----------'  Fax:   49-6151-164976
  89.                  !  D-6100 Darmstadt ! E-Mail:
  90.                  !  (Germany)        !     mnl@dtro.e-technik.th-darmstadt.de
  91. -----------------'-------------------'-----------------------------------------
  92.  
  93.