Bug 27519 - Another's class destructor name
Summary: Another's class destructor name
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.4
: P3 normal
Target Milestone: 4.0.3
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-09 15:52 UTC by Becheru Petru
Modified: 2006-05-10 08:06 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.1.0 4.2.0 3.4.0 3.4.6 4.0.3
Known to fail: 4.0.0 4.0.1 4.0.2
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Becheru Petru 2006-05-09 15:52:14 UTC
if u have 2 classes defined as:

class TPoints
	{
	TPoints(const TPoints&);
	TPoints& operator=(const TPoints&);
	friend class TPoligon;
	public:

	TPoints::TPoints(){}
	virtual ~TPoints();

	};

class TPoligon: public TPoints
	{
	TPoligon(const TPoligon&);//not impl
	TPoligon& operator=(const TPoligon&);//not impl

	public:

	TPoligon(){}
	virtual ~TPoligon();
	};

//and the functions
TPoints::~TPoligon()// !!!!! <-------- class TPoints and destructor of TPoligon
	{
	}

TPoints::~TPoints(){}

TPoligon::~TPoligon(){}

int main(){}


the code above compiles without warning!
Comment 1 David Fang 2006-05-09 18:34:18 UTC
With the following reduced case:

//--------->8 snip 8<-------------
class TPoints {
public:
~TPoints();
};

class TPoligon: public TPoints {
public:
~TPoligon();
};

TPoints::~TPoligon() { }

TPoints::~TPoints(){}
//--------->8 snip 8<------------

I get this misleading diagnostic with 4.0.1 (don't have 4.0.3 handy):
dtor.cc:13: error: redefinition of 'TPoints::~TPoints()'
dtor.cc:11: error: 'TPoints::~TPoints()' previously defined here

With 4.1, I get:
dtor.cc:11: error: declaration of '~TPoligon' as member of 'TPoints'
Comment 2 Richard Biener 2006-05-10 08:06:08 UTC
Fixed in 4.0.3:

/tmp> /space/rguenther/install/gcc-4.0.3/bin/g++ -Wall -S t.C
t.C:11: error: declaration of '~TPoligon' as member of 'TPoints'