fork download
  1. #include <iostream>
  2.  
  3. struct Stillborn
  4. {
  5. Stillborn()
  6. {
  7. std::cout << "inside constructor\n";
  8. throw 42;
  9. }
  10.  
  11. ~Stillborn()
  12. {
  13. // This text will never be printed:
  14. std::cout << "inside destructor\n";
  15. }
  16. };
  17.  
  18. int main()
  19. {
  20. try
  21. {
  22. Stillborn x;
  23. }
  24. catch (...)
  25. {
  26. std::cout << "inside catch block\n";
  27. }
  28. }
  29.  
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
inside constructor
inside catch block