Title
Branching into try block
Status
tc1
Section
18 [except]
Submitter
Jack Rouse

Created on 1999-02-23.00:00:00 last changed 208 months ago

Messages

Date: 2000-11-18.00:00:00

Proposed resolution (10/00:

Change text in 18 [except] paragraph 2 from:

A goto, break, return, or continue statement can be used to transfer control out of a try block or handler, but not into one.
to:
A goto or switch statement shall not be used to transfer control into a try block or into a handler.
[ Example:
void f() {
  goto l1;  // Ill-formed
  goto l2;  // Ill-formed
  try {
    goto l1;  // OK
    goto l2;  // Ill-formed
    l1: ;
  } catch (...) {
    l2: ;
    goto l1;  // Ill-formed
    goto l2;  // OK
  }
}
end example ]
A goto, break, return, or continue statement can be used to transfer control out of a try block or handler.

(See also issue 246.)

Date: 2004-09-10.00:00:00

At the top of clause 15, in paragraph 2, it says:

A goto, break, return, or continue statement can be used to transfer control out of a try block or handler, but not into one.
What about switch statements?
    switch ( f() )
    {
    case 1:
         try {
             g();
    case 2:
             h();
         }
         catch (...)
         {
             // handler
         }
    break;
    }
Daveed Vandevoorde:

Consider:

    void f() {
        try {
        label:
            ;
        } catch(...) {
            goto label;
        }
    }
Now the phrase "try block" (without a hyphen) is used in paragraph 1 in a way that causes me to think that it is not intended to include the corresponding handlers. On the other hand, the grammar entity "try-block" (with hyphen) does include the handlers. So is the intent to prohibit the above or not?
History
Date User Action Args
2003-04-25 00:00:00adminsetstatus: dr -> tc1
2000-11-18 00:00:00adminsetmessages: + msg456
2000-11-18 00:00:00adminsetstatus: ready -> dr
2000-05-21 00:00:00adminsetstatus: drafting -> ready
2000-02-23 00:00:00adminsetstatus: open -> drafting
1999-02-23 00:00:00admincreate