Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!allegra.tempo.nj.att.com!fox From: fox@allegra.tempo.nj.att.com (David Fox) Newsgroups: gnu.g++.bug Subject: destructor called for object that never was Message-ID: <9001022130.AA26007@life.ai.mit.edu> Date: 2 Jan 90 21:30:07 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 21 I am running the g++ from interviews of December 21 on a sun-4. The program below constructs an "X" only when the if condition is satisfied, but it mistakenly destructs it regardless. Enclosing the for statment in braces is a workaround. Cfront behaves correctly. #include class X { int a; public: X() : a(123) {} X(int n) : a(n) {} ~X() {cout << "Deleting " << a << "\n";} }; main(int ac) { if (ac > 1) for (X x(5); ac > 0; ac--); }