Thread View: gnu.g++.bug
2 messages
2 total messages
Started by Tom Vijlbrief
Wed, 28 Jun 1989 10:23
g++1.35 evaluates expression twice when destructor is virtual
Author: Tom Vijlbrief
Date: Wed, 28 Jun 1989 10:23
Date: Wed, 28 Jun 1989 10:23
56 lines
1963 bytes
1963 bytes
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
===============================================================================
g++1.35 evaluates expression twice when destructor is virtual
Author: Michael Tiemann
Date: Tue, 01 Aug 1989 02:44
Date: Tue, 01 Aug 1989 02:44
20 lines
994 bytes
994 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads