[gnu.g++.bug] g++ 1.35.1- error in "delete [xxx] yyy"

tietz@gmdzi.UUCP (Christoph Tietz) (09/29/89)

I just encountered a really nasty bug in g++ 1.35.1- under SunOS4.0.3 on
a SUN3. It boils down to the following:

If you spezify the size in a delete statement as in "delete [100] chr_ptr"
g++ will generate NO code at all for the delete statement. All is well again,
if you just write "delete chr_ptr". We found this problem in form of a
memory leak in a program that depends heavily on the generic vector classes
of libg++.

Here a trivial example:

g++ version 1.35.1-
 /gmdusr/g++/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus
                         -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__
                         -D__unix__ -D__HAVE_68881__ -Dmc68020 leak.cc
                         /tmp/cca03938.cpp
GNU CPP version 1.35
 /gmdusr/g++/lib/gcc-cc1plus /tmp/cca03938.cpp -quiet -dumpbase leak.cc
                             -noreg -version -o leak.s
GNU C++ version 1.35.1- (68k, MIT syntax) compiled by GNU C version 1.35.

-----

main () {
  char *p;

  p = new char [100];
  delete [100] p;
}

-----

generates the following code:

-----

#NO_APP
gcc_compiled.:
.text
	.even
.globl _main
_main:
	link a6,#-4
	pea 100:w
	jbsr ___builtin_new
	movel d0,a6@(-4)
	addqw #4,sp
L1:
	unlk a6
	rts

-----

There is obviously no sign of a call to ___builtin_delete.
But I think there should be %-(

                                                   Christoph Tietz

-- 
GMD,  Schloss Birlinghoven,  Postfach 1240,  D-5205 St. Augustin 1,  FRG

e-mail:  tietz@zi.gmd.dbp.de                tietz@gmdzi.uucp
         tietz%zi.gmd.dbp.de@relay.cs.net   ... !uunet!unido!gmdzi!tietz