delete not called

Tudor Hulubei tudor@cs.unh.edu
Thu Apr 16 23:59:00 GMT 1998


Hi there,

I think there is a bug in recent snapshots of egcs.  For the appended
example there is no call to operator delete generated for objects of
type Y, so the output looks like:

new: 0x8049928
new: 0x8049938
delete: 0x8049928

gcc-2.8.1 & gcc-2.7.2.3 (and I believe older snapshots of egcs) do
generate the call.

Is this a known problem?

Thanks,
Tudor

P.S.  The version I use is:
Reading specs from /home/tudor/usr/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.22/specs
gcc version egcs-2.91.22 980404 (gcc2 ss-980401 experimental)

#include <new>
#include <iostream.h>
#include <stdlib.h>

void *operator new(size_t size)
{
    if (void *ptr = malloc(size)) {
	cerr << "new: " << ptr << endl;
	return ptr;
    }
}

void operator delete(void *ptr)
{
    if (ptr) {
	cerr << "delete: " << ptr << endl;
	free(ptr);
    }
}

class X { public: ~X() {} };
class Y : public X {};

int
main()
{
    X *x = new X();
    Y *y = new Y();

    delete x;
    delete y;
}



More information about the Gcc mailing list