This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
destructor of referenced object doesn't work
- To: gcc-bugs at gcc dot gnu dot org
- Subject: destructor of referenced object doesn't work
- From: Takashi Sasaki <takasi-s at is dot aist-nara dot ac dot jp>
- Date: Tue, 25 Jan 2000 12:49:30 +0900
- Cc: Takashi SASAKI <takasi-s at is dot aist-nara dot ac dot jp>
version gcc version 2.95.2 19991024 (release)
OS DEC Alpha OSF1 (Compaq True64)
In the following code, destructor of TestClass doesn't called.
When the reference 'r' is out of scope, the destructor must
be called.
------------------------------------------------------
class TestClass
{
public:
TestClass(void){cout <<"constructed." << endl;}
~TestClass(){cout << "destructed." << endl;}
};
int main (void)
{
for(int i=0; i<10 ; i++) {
TestClass& r = *new TestClass ;
}
}
-------------------------------------------------------
Takash SASAKI <tsasaki@windy.cx>
Nara Institute of Science and Technology, Japan