Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8212841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:54:24+00:00 2026-06-07T10:54:24+00:00

I have some code that I’ve inherited from someone very clever where they like

  • 0

I have some code that I’ve inherited from someone very clever where they like to use gotos to leave the try block, jumping completely around the catch blocks.

It definitely works, and I suspect this is legal (I think that the C++ standard says that on exit from a scope, everything gets cleaned up properly, and I assume that applies to whatever the compiler had to do to implement exceptions on my platform).

Is this really legit? It’s NOT something I’d ever write (it’s too clever by half), but it’s clearly working, and I just want to understand why this is OK.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:54:25+00:00Added an answer on June 7, 2026 at 10:54 am

    Even more specifically than the C++03 standard’s section on jump statements, it says this about try-blocks in the “Exception handling” clause (15/2):

    A goto, break, return, or continue statement can be used to transfer
    control out of a try block or handler. When this happens, each
    variable declared in the try block will be destroyed in the context
    that directly contains its declaration.

    C++11 contains the same wording.

    Note however, that’s it’s not OK to jump into a try-block using a goto (or switch):

    A goto or switch statement shall not be used to transfer control into a try block or into a handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that written in php to use for export data from
I have some code that looks like this: foreach(var obj in collection) { try
I have some code that makes heavy use of a thread pool, which I
I have some code that reads from a file, and outputs the Fibonacchi numbers.
I have some code that is basically 5 print statements that i would like
I have some code that looks something like this: d = {'foo': True, 'bar':
I have some code that downloads a file from the internet located here: http://www.amsat.org/amsat/ftp/keps/current/nasa.all
I have some code that uses subprocess to look at the logs from a
I have some code that I have inherited that generates a matrix of significance
I have some code that is structured as follows from my.modules import MyClass Class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.