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

  • Home
  • SEARCH
  • 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 3488452
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:16:21+00:00 2026-05-18T11:16:21+00:00

Can compiler reorder variable setting and throw() op in C++? Or, does standard C++

  • 0

Can compiler reorder variable setting and throw() op in C++? Or, does standard C++ 14882-1998 allows or prohibit compiler of this transform?

For code:

bool funct()
{
    bool succeeded = false;
    bool res_throw = false;

        try {
            throw("it");
            succeeded = true;
        }
        catch(...) {
            res_throw = true;
        }

        cout << "Result of throw: " << res_throw << endl;
        cout << "succeeded: " << succeeded << endl;

    return succeeded;
}

Can the output be a

Result of throw: true
succeeded: true

The Standard says: “[intro.execution]#7”:

modifying an object .. are all side
effects, which are changes in the
state of the execution environment

At certain specified points in the execution sequence called sequence points, all side effects of previous evaluations shall be complete and no side effects of subsequent evaluations shall have taken place

Is throw statement a sequence point?

  • 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-05-18T11:16:22+00:00Added an answer on May 18, 2026 at 11:16 am

    Yes, there is a sequence point associated with the throw statement, because there is a sequence point at the end of every statement.

    So succeeded must remain false in your example.

    I don’t have the C++98 Standard, but in the C++03 Standard:

    1.9p16: There is a sequence point at the completion of each full-expression.

    A statement is the simplest kind of “full-expression”, but the Standard is worded to include other expressions that are not technically part of any statement.

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

Sidebar

Related Questions

What does a JIT compiler specifically do as opposed to a non-JIT compiler? Can
Although the MTASC command-line compiler can compile ActionScript class files into an SWF ,
The v4 series of the gcc compiler can automatically vectorize loops using the SIMD
In Delphi, you can use compiler directives to disable specific warnings, such as {$WARN
C# doesn't require you to specify a generic type parameter if the compiler can
Although the Flex command-line compiler (mxmlc) can compile MXML + ActionScript files into SWFs
In C and C++ you can tell the compiler that a number is a
Just out of curiosity: I know I can tell the compiler if I want
Is there a #define compiler (nvcc) macro of CUDA which I can use? (Like
On the MSVC++ compiler, one can use the __int8 , __int16 , __int32 and

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.