Sequence Points in C ++ and Exceptions

Can a variable parameter reorder the compiler and throw()op in C ++? Or, does standard C ++ 14882-1998 enable or disable the compiler of this conversion?

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;
}

Could there be a way out

Result of throw: true
succeeded: true

The standard says: "[intro.execution] # 7":

object change .. all side effects that are changes to the state of the runtime

At certain specific points in the execution sequence, called sequence points, all side effects of previous evaluations should be complete and no side effects of subsequent evaluations should be

Is a throwsequence point expression?

+3
source share
2

, , throw, .

, succeeded false .

++ 98, ++ 03:

1.9p16: .

" ", , - .

+4

- . , succeeded true

EDIT: : succeeded true

+4

Source: https://habr.com/ru/post/1778795/


All Articles