www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - [bug] throwing exception in destructor

If an exception is thrown in a destructor, the destructors of subobjects
aren't called, the expected output from the following test-case is:

A::A
A::A
throw 0
A::~A
A::~A
caught

but with DMC 8.44.6n I get:

A::A
A::A
throw 0
caught


test-case:

#include <stdio.h>

struct A
{
  A()
  {
    printf("A::A\n");
  }

  ~A()
  {
    printf("A::~A\n");
  }
};

struct B : A
{
  A a;

  ~B()
  {
    printf("throw 0\n");
    throw 0;
  }
};


int main()
{
  try
  {
    B b;
  }
  catch (const int &)
  {
    printf("caught\n");
  }

  return 0;
}


bye, Christof

-- 
http://cmeerw.org
mailto:cmeerw at web.de                       xmpp:cmeerw at cmeerw.org

...and what have you contributed to the Net?
Aug 06 2005