fork download
  1. #include <iostream>
  2.  
  3. struct X
  4. {
  5. X(const char *str): str(str)
  6. {
  7. std::cout << "X(" << str << ")" << std::endl;
  8. }
  9.  
  10. ~X()
  11. {
  12. std::cout << "~X(" << str << ")" << std::endl;
  13. }
  14. const char *str;
  15. };
  16.  
  17. int main()
  18. {
  19. void *ptr_out;
  20. ptr_out = &&out;
  21. std::cout << "Before block" << std::endl;
  22. {
  23. std::cout << "In block" << std::endl;
  24. X x("x");
  25. X y("y");
  26. std::cout << "Leaving block via goto" << std::endl;
  27. goto *ptr_out;
  28. //goto out;
  29. std::cout << "Never executed" << std::endl;
  30. }
  31. out:
  32. std::cout << "Left block" << std::endl;
  33.  
  34. return 0;
  35. }
Success #stdin #stdout 0s 4528KB
stdin
Standard input is empty
stdout
Before block
In block
X(x)
X(y)
Leaving block via goto
Left block