1 // { dg-do run  }
2 //  Copyright (C) 1999 Free Software Foundation, Inc.
3 //  Contributed by Nathan Sidwell 21 Nov 1999 <nathan@acm.org>
4 
5 // make sure we don't call base dtors, if we failed to call the
6 // base ctor due to exception throwing
7 
8 #include <stdio.h>
9 
10 static bool bad = false;
11 
thrower()12 static int thrower ()
13 {
14   printf ("in %s\n", __PRETTY_FUNCTION__);
15   throw 0;
16   return 0;
17 }
18 
19 struct X
20 {
21   X (int) throw (int);
22   ~X () throw ();
23 };
24 
X(int)25 X::X (int) throw (int)
26   {printf ("in ctor X %s\n", __PRETTY_FUNCTION__); bad = true;}
~X()27 X::~X () throw ()
28   {printf ("in dtor X %s\n", __PRETTY_FUNCTION__); bad = true;}
29 
30 struct X1 {};
31 struct Y : X
32 {
33   Y() throw (int);
34   ~Y() throw ();
35 };
Y()36 Y::Y() throw (int)
37   : X(thrower ())   // throws, so X::X is never called
38   {printf ("in ctor Y%s\n", __PRETTY_FUNCTION__); bad = true;}
~Y()39 Y::~Y() throw ()
40   {printf ("in dtor Y%s\n", __PRETTY_FUNCTION__); bad = true;}
41 
main()42 int main ()
43 {
44   try
45     {
46       Y y;
47     }
48   catch (...)
49     {
50       printf ("caught\n");
51     }
52   return bad;
53 }
54