1 // { dg-do run } 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <exception> 5 6 static void eh_terminate()7eh_terminate () 8 { 9 printf ("CALLING TERMINATE\n"); 10 exit (1); 11 } 12 13 void eh_test(int level)14eh_test (int level) 15 { 16 try 17 { 18 if (level < 2) 19 eh_test (level + 1); 20 else 21 { 22 printf ("%d: Throwing\n", level); 23 throw (level); 24 } 25 } 26 catch (int &x) 27 { 28 printf ("%d: Got level %d\n", 29 level, x); 30 31 if (level > 0) 32 throw; 33 } 34 } 35 main()36int main () 37 { 38 std::set_terminate (&eh_terminate); 39 eh_test (0); 40 } 41