56 lines · cpp
1#include <stdio.h>2 3class ExcA {};4class ExcB {};5class ExcC {};6class ExcD {};7class ExcE {};8class ExcF {};9class ExcG {};10 11void foo(int a)12{13 if (a > 1)14 throw ExcG();15 else16 throw ExcC();17}18 19void never_throws() throw () {20 printf("this statement is cold and should be outlined\n");21}22 23int main(int argc, char **argv)24{25 for (unsigned i = 0; i < 1000; ++i) {26 try {27 if (argc == 2) {28 never_throws(); // should be cold29 }30 try {31 if (argc == 2) {32 never_throws(); // should be cold33 }34 throw ExcA();35 } catch (ExcA) {36 printf("catch 2\n");37 throw new int();38 }39 } catch (...) {40 printf("catch 1\n");41 }42 43 try {44 try {45 foo(argc);46 } catch (ExcC) {47 printf("caught ExcC\n");48 }49 } catch (ExcG) {50 printf("caught ExcG\n");51 }52 }53 54 return 0;55}56