abicheck.cc 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Bug 25485: Browser/TorBrowser/Tor/libstdc++.so.6: version `CXXABI_1.3.11' not found
  3. * This program is borrowed from
  4. * https://en.cppreference.com/w/cpp/error/uncaught_exception and is useful in
  5. * determining the latest C++ ABI. Specifically this program requires
  6. * `GLIBCXX_3.4.22` which we use to compare the version of the installed
  7. * libstdc++.so.6 and the bundled version. If the program executes
  8. * successfully, that means we should use the system version of libstdc++.so.6
  9. * and if not, that means we should use the bundled version.
  10. */
  11. #include <iostream>
  12. #include <exception>
  13. #include <stdexcept>
  14. struct Foo {
  15. int count = std::uncaught_exceptions();
  16. ~Foo() {
  17. std::cout << (count == std::uncaught_exceptions()
  18. ? "~Foo() called normally\n"
  19. : "~Foo() called during stack unwinding\n");
  20. }
  21. };
  22. int main()
  23. {
  24. Foo f;
  25. try {
  26. Foo f;
  27. std::cout << "Exception thrown\n";
  28. throw std::runtime_error("test exception");
  29. } catch (const std::exception& e) {
  30. std::cout << "Exception caught: " << e.what() << '\n';
  31. }
  32. }