public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "wolfgang dot roehrl at de dot gi-de dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/15097] New: code generator problem with ::delete and multiple inheritance Date: Fri, 23 Apr 2004 11:05:00 -0000 [thread overview] Message-ID: <20040423110112.15097.wolfgang.roehrl@de.gi-de.com> (raw) Used invokation line for the C++ compiler: ccppc -c -x c++ -ansi -Wall -Werror -mcpu=8540 -fverbose-asm -mbig -mmultiple -mno-string -mstrict-align -O3 -fno-exceptions -fno-rtti -I<different include paths> -D<differen #define's> Z.CPP -oZ.O // example program class B1 { public: virtual ~B1 () throw(); protected: B1 (); private: int x; }; class B2 { public: virtual ~B2 () throw(); protected: B2 (); private: int x; }; class D : public B1, public B2 { public: D (); ~D () throw(); private: int y; }; void f1 (D*); void f2 (B2*); void f3 (B1*); void f (void) { f1 (::new D); f2 (::new D); // correct address adjustement D -> B2, see assembler listing f3 (::new D); } void f1 (D* p) { ::delete p; } void f2 (B2* p) { ::delete p; } // missing address adjustment B2 -> D for the call of ::operator delete() void f3 (B1* p) { ::delete p; } In function f2() the deallocation function ::operator delete() (assembler call 'bl _ZdlPv') is called, but the deallocation function does not get the address of the dynamic D-object. The corresponding assembler listing is attached below. I think that the code above is legal, cf. the C++ standard 5.3.4/9, 5.3.4/18 (for constructor exceptions) and 5.3.5/8. ************************************** assembler listing ************************************** .file "z.CPP" # rs6000/powerpc options: -mcpu=8540 -msdata=data # GNU C++ version 3.3-e500 20030421 (Wind River) (powerpc-wrs-vxworks) # compiled by GNU C version 3.2.2. # GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32684 # options passed: -I. -ID:\\GNU_NG\\target\\h # -ID:\\GNU_NG\\target\\h\\types -ID:\\GNU_NG\\target\\h\\arch\\ppc # -iprefix -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=0 # -DCPU=PPC85XX -DTOOL_FAMILY=gnu -DTOOL=gnu -D__GNUG__=3 -mcpu=8540 -mbig # -mmultiple -mno-string -mstrict-align -ansi -auxbase-strip -O3 -Wall # -Werror -ansi -fverbose-asm -fno-exceptions -fno-rtti -oz.ASS # options enabled: -fdefer-pop -fomit-frame-pointer # -foptimize-sibling-calls -fcse-follow-jumps -fcse-skip-blocks # -fexpensive-optimizations -fthread-jumps -fstrength-reduce -fpeephole # -fforce-mem -ffunction-cse -fkeep-static-consts -fcaller-saves # -freg-struct-return -fgcse -fgcse-lm -fgcse-sm -floop-optimize # -fcrossjumping -fif-conversion -fif-conversion2 -frerun-cse-after-loop # -frerun-loop-opt -fdelete-null-pointer-checks -fschedule-insns # -fschedule-insns2 -fsched-interblock -fsched-spec -fbranch-count-reg # -freorder-blocks -freorder-functions -frename-registers # -fcprop-registers -fcommon -fverbose-asm -fregmove # -foptimize-register-move -fargument-alias -fstrict-aliasing # -fmerge-constants -fzero-initialized-in-bss -fident -fpeephole2 # -fguess-branch-probability -fmath-errno -ftrapping-math -mpowerpc # -mpowerpc-gfxopt -mnew-mnemonics -mmultiple -mno-multiple -mno-string # -msched-prolog -msched-epilog -mstrict-align -meabi -mcpu=8540 # -mcall-sysv -msdata=data .globl _ZTV1D .section .rodata .align 3 .type _ZTV1D, @object .size _ZTV1D, 32 _ZTV1D: .long 0 .long 0 .long _ZN1DD1Ev .long _ZN1DD0Ev .long -8 .long 0 .long _ZThn8_N1DD1Ev .long _ZThn8_N1DD0Ev .section ".text" .align 2 .globl _ZN1DC2Ev .type _ZN1DC2Ev, @function _ZN1DC2Ev: stwu 1,-24(1) mflr 7 stmw 29,12(1) stw 7,28(1) mr 29,3 # this bl _ZN2B1C2Ev addi 3,29,8 # this, this bl _ZN2B2C2Ev lis 3,_ZTV1D+24@ha la 0,_ZTV1D+24@l(3) lwz 3,28(1) lis 5,_ZTV1D+8@ha li 6,1 la 4,_ZTV1D+8@l(5) stw 6,16(29) # <variable>.y stw 4,0(29) # <variable>._vptr$B1 mtlr 3 stw 0,8(29) # <variable>._vptr$B2 lmw 29,12(1) addi 1,1,24 blr .size _ZN1DC2Ev, .-_ZN1DC2Ev .align 2 .globl _ZN1DC1Ev .type _ZN1DC1Ev, @function _ZN1DC1Ev: stwu 1,-24(1) mflr 7 stmw 29,12(1) stw 7,28(1) mr 29,3 # this bl _ZN2B1C2Ev addi 3,29,8 # this, this bl _ZN2B2C2Ev lis 3,_ZTV1D+24@ha la 0,_ZTV1D+24@l(3) lwz 3,28(1) lis 5,_ZTV1D+8@ha li 6,1 la 4,_ZTV1D+8@l(5) stw 6,16(29) # <variable>.y stw 4,0(29) # <variable>._vptr$B1 mtlr 3 stw 0,8(29) # <variable>._vptr$B2 lmw 29,12(1) addi 1,1,24 blr .size _ZN1DC1Ev, .-_ZN1DC1Ev .align 2 .globl _ZN1DD2Ev .type _ZN1DD2Ev, @function _ZN1DD2Ev: stwu 1,-24(1) lis 6,_ZTV1D+8@ha lis 5,_ZTV1D+24@ha mflr 7 la 0,_ZTV1D+24@l(5) stmw 29,12(1) li 4,-1 mr 29,3 # this stw 7,28(1) la 3,_ZTV1D+8@l(6) stw 0,8(29) # <variable>._vptr$B2 stw 3,0(29) # <variable>._vptr$B1 addi 3,29,8 # this, this stw 4,16(29) # <variable>.y bl _ZN2B2D2Ev mr 3,29 # this bl _ZN2B1D2Ev lmw 29,12(1) lwz 3,28(1) addi 1,1,24 mtlr 3 blr .size _ZN1DD2Ev, .-_ZN1DD2Ev .align 2 .globl _ZN1DD1Ev .type _ZN1DD1Ev, @function _ZN1DD1Ev: stwu 1,-24(1) lis 6,_ZTV1D+8@ha lis 5,_ZTV1D+24@ha mflr 7 la 0,_ZTV1D+24@l(5) stmw 29,12(1) li 4,-1 mr 29,3 # this stw 7,28(1) la 3,_ZTV1D+8@l(6) stw 0,8(29) # <variable>._vptr$B2 stw 3,0(29) # <variable>._vptr$B1 addi 3,29,8 # this, this stw 4,16(29) # <variable>.y bl _ZN2B2D2Ev mr 3,29 # this bl _ZN2B1D2Ev lmw 29,12(1) lwz 3,28(1) addi 1,1,24 mtlr 3 blr .size _ZN1DD1Ev, .-_ZN1DD1Ev .align 2 .globl _ZThn8_N1DD1Ev .type _ZThn8_N1DD1Ev, @function _ZThn8_N1DD1Ev: addi 3,3,-8 b _ZN1DD1Ev .size _ZThn8_N1DD1Ev, .-_ZThn8_N1DD1Ev .align 2 .globl _ZN1DD0Ev .type _ZN1DD0Ev, @function _ZN1DD0Ev: stwu 1,-24(1) lis 6,_ZTV1D+8@ha lis 5,_ZTV1D+24@ha mflr 7 la 0,_ZTV1D+24@l(5) stmw 29,12(1) li 4,-1 mr 29,3 # this stw 7,28(1) la 3,_ZTV1D+8@l(6) stw 0,8(29) # <variable>._vptr$B2 stw 4,16(29) # <variable>.y stw 3,0(29) # <variable>._vptr$B1 addi 3,29,8 # this, this bl _ZN2B2D2Ev mr 3,29 # this bl _ZN2B1D2Ev mr 3,29 # this bl _ZdlPv lmw 29,12(1) lwz 3,28(1) addi 1,1,24 mtlr 3 blr .size _ZN1DD0Ev, .-_ZN1DD0Ev .align 2 .globl _ZThn8_N1DD0Ev .type _ZThn8_N1DD0Ev, @function _ZThn8_N1DD0Ev: addi 3,3,-8 b _ZN1DD0Ev .size _ZThn8_N1DD0Ev, .-_ZThn8_N1DD0Ev .align 2 .globl _Z1fv .type _Z1fv, @function _Z1fv: stwu 1,-40(1) mflr 3 stw 3,44(1) stmw 25,12(1) li 3,20 li 25,1 bl _Znwj mr 28,3 # this bl _ZN2B1C2Ev addi 3,28,8 # this, this bl _ZN2B2C2Ev lis 4,_ZTV1D+24@ha lis 5,_ZTV1D+8@ha stw 25,16(28) # <variable>.y la 26,_ZTV1D+8@l(5) la 27,_ZTV1D+24@l(4) stw 26,0(28) # <variable>._vptr$B1 mr 3,28 # this stw 27,8(28) # <variable>._vptr$B2 bl _Z2f1P1D li 3,20 bl _Znwj addi 28,3,8 # this, this mr 29,3 # this bl _ZN2B1C2Ev mr 3,28 # this bl _ZN2B2C2Ev stw 27,8(29) # <variable>._vptr$B2 stw 25,16(29) # <variable>.y mr 3,28 # this stw 26,0(29) # <variable>._vptr$B1 bl _Z2f2P2B2 li 3,20 bl _Znwj mr 28,3 # this bl _ZN2B1C2Ev addi 3,28,8 # this, this bl _ZN2B2C2Ev stw 25,16(28) # <variable>.y stw 26,0(28) # <variable>._vptr$B1 mr 3,28 # this stw 27,8(28) # <variable>._vptr$B2 bl _Z2f3P2B1 lmw 25,12(1) lwz 3,44(1) addi 1,1,40 mtlr 3 blr .size _Z1fv, .-_Z1fv .align 2 .globl _Z2f1P1D .type _Z2f1P1D, @function _Z2f1P1D: stwu 1,-24(1) mflr 4 cmpwi 0,3,0 # p stw 31,20(1) mr 31,3 # p stw 4,28(1) beq- 0,.L21 lwz 5,0(3) # <variable>._vptr$B1 lwz 0,0(5) mtctr 0 bctrl mr 3,31 # p bl _ZdlPv .L21: lwz 3,28(1) lwz 31,20(1) addi 1,1,24 mtlr 3 blr .size _Z2f1P1D, .-_Z2f1P1D .align 2 .globl _Z2f2P2B2 .type _Z2f2P2B2, @function _Z2f2P2B2: stwu 1,-24(1) mflr 4 cmpwi 0,3,0 # p stw 31,20(1) mr 31,3 # p stw 4,28(1) beq- 0,.L24 lwz 5,0(3) # <variable>._vptr$B2 lwz 0,0(5) mtctr 0 bctrl mr 3,31 # p bl _ZdlPv .L24: lwz 3,28(1) lwz 31,20(1) addi 1,1,24 mtlr 3 blr .size _Z2f2P2B2, .-_Z2f2P2B2 .align 2 .globl _Z2f3P2B1 .type _Z2f3P2B1, @function _Z2f3P2B1: stwu 1,-24(1) mflr 4 cmpwi 0,3,0 # p stw 31,20(1) mr 31,3 # p stw 4,28(1) beq- 0,.L27 lwz 5,0(3) # <variable>._vptr$B1 lwz 0,0(5) mtctr 0 bctrl mr 3,31 # p bl _ZdlPv .L27: lwz 3,28(1) lwz 31,20(1) addi 1,1,24 mtlr 3 blr .size _Z2f3P2B1, .-_Z2f3P2B1 .ident "GCC: (GNU) 3.3-e500 20030421 (Wind River)" -- Summary: code generator problem with ::delete and multiple inheritance Product: gcc Version: 3.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: wolfgang dot roehrl at de dot gi-de dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: sparc-sun-solaris2.5.1 GCC host triplet: i386-pc-mingw32 GCC target triplet: powerpc-wrs-vxworks http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15097
next reply other threads:[~2004-04-23 11:01 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-04-23 11:05 wolfgang dot roehrl at de dot gi-de dot com [this message] 2004-04-23 13:26 ` [Bug c++/15097] code generator problem with ::delete and multiple inheritance and virtual deconstructs pinskia at gcc dot gnu dot org 2004-05-04 19:30 ` pinskia at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20040423110112.15097.wolfgang.roehrl@de.gi-de.com \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).