home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / gnu / g / help / 1226 < prev    next >
Encoding:
Text File  |  1992-09-13  |  1.4 KB  |  57 lines

  1. Path: sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!bu.edu!transfer!bluefuzz.sw.stratus.com!lee
  2. From: lee@bluefuzz.sw.stratus.com (Lee Cooprider)
  3. Newsgroups: gnu.g++.help
  4. Subject: Problem with virtual destructors
  5. Message-ID: <6334@transfer.stratus.com>
  6. Date: 13 Sep 92 23:08:14 GMT
  7. Sender: usenet@transfer.stratus.com
  8. Distribution: gnu
  9. Organization: Stratus Computer, Software Engineering
  10. Lines: 45
  11.  
  12. I am using C++ from gcc version 2.2.1 on a Sparc platform.
  13.  
  14. My problem is with virtual destructors.  Whenever my real destructor is
  15. called, the program abort()'s after executing the destructor successfully.
  16.  
  17. This program illustrates the problem:
  18.  
  19.     class aaa {
  20.       public:
  21.         virtual ~aaa() = 0;};
  22.     
  23.     class bbb : public aaa {
  24.       public:
  25.         bbb();
  26.         ~bbb();};
  27.     
  28.     bbb::bbb() {}
  29.     bbb::~bbb() {}
  30.  
  31. The assembler for ~bbb() has an unconditional abort() call at the end.  Is
  32. this the correct code?  Is there an additional requirement on virtual
  33. destructors?  Is it not legal for a destructor to be pure-virtual?
  34.  
  35. This is the assembler code for the ~bbb() routine above:
  36.  
  37.     __$_3bbb:
  38.         !#PROLOGUE# 0
  39.         save %sp,-112,%sp
  40.         !#PROLOGUE# 1
  41.         mov %i0,%l0
  42.         st %i1,[%fp+72]
  43.         sethi %hi(__vt$bbb),%o1
  44.         or %o1,%lo(__vt$bbb),%o0
  45.         st %o0,[%l0]
  46.     L4:
  47.         mov %l0,%o0
  48.         ld [%fp+72],%o1
  49.         call _abort,0
  50.         nop
  51.     L3:
  52.         ret
  53.         restore
  54. -- 
  55. Lee W. Cooprider                PP-ASEL/IA
  56. Lee_Cooprider@vos.stratus.com            Skylane N2908F "Wiley"
  57.