tom@tnosoes.UUCP (Tom Vijlbrief) (06/28/89)
G++ evaluates the expression b.delfunc(this) twice. Discovered when porting ET++ g++ version 1.35.0 /usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 doubledel.cc /tmp/cca04906.cpp GNU CPP version 1.35 /usr/local/lib/gcc-cc1plus /tmp/cca04906.cpp -quiet -dumpbase doubledel.cc -noreg -version -o /tmp/cca04906.s GNU C++ version 1.35.0 (68k, MIT syntax) compiled by GNU C version 1.35. /usr/local/lib/gcc-as -mc68020 /tmp/cca04906.s -o doubledel.o /usr/local/lib/gcc-ld++ -C /usr/local/lib/crt0+.o /lib/Mcrt1.o doubledel.o -lg++ /usr/local/lib/gcc-gnulib -lc tom@twilight:~/src/CC> a.out called called ================================================= #include <stdio.h> class del { public: del() {}; virtual ~del() {}; virtual void bug(); virtual del *delfunc(del*); }; del b; del *del::delfunc(del*) { del *p= new del; fprintf(stderr, "called\n"); return p; } void del::bug() { delete b.delfunc(this); // b.delfunc(this) is called twice !!! } main() { del *a= new del; a->bug(); } =============================================================================== Tom Vijlbrief TNO Institute for Perception P.O. Box 23 Phone: +31 34 63 562 11 3769 ZG Soesterberg E-mail: tnosoes!tom@mcvax.cwi.nl The Netherlands or: uunet!mcvax!tnosoes!tom ===============================================================================
tiemann@YAHI.STANFORD.EDU (Michael Tiemann) (08/01/89)
G++ evaluates the expression b.delfunc(this) twice.
Discovered when porting ET++ [...]
Here is the fix (to function build_delete, near the top of the function):
*** cplus-init.c~ Fri Jul 28 14:56:18 1989
--- cplus-init.c Mon Jul 31 19:39:05 1989
***************
*** 2704,2707 ****
--- 2704,2709 ----
return expr;
}
+ if (TREE_VOLATILE (addr))
+ addr = save_expr (addr);
ref = build_indirect_ref (addr, 0);
ptr = 1;
yahi%
Michael