This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

destructor of referenced object doesn't work


  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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]