MI destructor bug

matthew@ooc.com matthew@ooc.com
Thu Aug 27 15:42:00 GMT 1998


#include <iostream.h>

class a
{
public:
    a() { cout << "a: " << this << endl; }
    virtual ~a() { cout << "~a: " << this << endl; }
};

class b : public virtual a
{
public:
    b() { cout << "b: " << this << endl; }
    virtual ~b() { cout << "~b: " << this << endl; }
};

class c : public virtual b
{
public:
    c() { cout << "c: " << this << endl; }
    virtual ~c() { cout << "~c: " << this << endl; }
};

class d : public virtual c
{
public:
    d() { throw 1; cout << "d: " << this << endl; }
    virtual ~d() { cout << "~d: " << this << endl; }
};

int
main()
{
    try
    {
	d dd;
    }
    catch(int a)
    {
    }
}

This application with egcs-1.0.3a reports

a: 0xbffff734
b: 0xbffff738
c: 0xbffff73c

I believe the correct output should be:

a: 0x7fff2f3c
b: 0x7fff2f34
c: 0x7fff2f28
~c: 0x7fff2f28
~b: 0x7fff2f34
~a: 0x7fff2f3c

Matthew
-- 
Matthew Newhook				E-Mail: mailto:matthew@ooc.com
Software Designer			WWW:    http://www.ooc.com
Object Oriented Concepts, Inc.		Phone:  (978) 439 9285 x 246



More information about the Gcc-bugs mailing list