@with_both_exception_handling
def test_exceptions_uncaught(self):
    self.set_setting('EXIT_RUNTIME', 1)
    src = '\n      #include <stdio.h>\n      #include <exception>\n      struct X {\n        ~X() {\n          printf("exception? %s\\n", std::uncaught_exception() ? "yes" : "no");\n        }\n      };\n      int main() {\n        printf("exception? %s\\n", std::uncaught_exception() ? "yes" : "no");\n        try {\n          X x;\n          throw 1;\n        } catch(...) {\n          printf("exception? %s\\n", std::uncaught_exception() ? "yes" : "no");\n        }\n        printf("exception? %s\\n", std::uncaught_exception() ? "yes" : "no");\n        return 0;\n      }\n    '
    self.do_run(src, 'exception? no\nexception? yes\nexception? no\nexception? no\n')
    src = '\n      #include <fstream>\n      #include <iostream>\n      int main() {\n        std::ofstream os("test");\n        os << std::unitbuf << "foo"; // trigger a call to std::uncaught_exception from\n                                     // std::basic_ostream::sentry::~sentry\n        std::cout << "success";\n      }\n    '
    self.do_run(src, 'success')
@with_both_exception_handling
def test_exceptions_uncaught(self):
    self.set_setting('EXIT_RUNTIME', 1)
    src = '\n      #include <stdio.h>\n      #include <exception>\n      struct X {\n        ~X() {\n          printf("exception? %s\\n", std::uncaught_exception() ? "yes" : "no");\n        }\n      };\n      int main() {\n        printf("exception? %s\\n", std::uncaught_exception() ? "yes" : "no");\n        try {\n          X x;\n          throw 1;\n        } catch(...) {\n          printf("exception? %s\\n", std::uncaught_exception() ? "yes" : "no");\n        }\n        printf("exception? %s\\n", std::uncaught_exception() ? "yes" : "no");\n        return 0;\n      }\n    '
    self.do_run(src, 'exception? no\nexception? yes\nexception? no\nexception? no\n')
    src = '\n      #include <fstream>\n      #include <iostream>\n      int main() {\n        std::ofstream os("test");\n        os << std::unitbuf << "foo"; // trigger a call to std::uncaught_exception from\n                                     // std::basic_ostream::sentry::~sentry\n        std::cout << "success";\n      }\n    '
    self.do_run(src, 'success')