Cello icon indicating copy to clipboard operation
Cello copied to clipboard

return in a `try` block breaks `Exception_Depth()`

Open To1ne opened this issue 11 years ago • 3 comments

For example.

bool IsItOne(int i) {
  try {
    if (1 == i) return true;
  } catch (e) {
    ;
  }
  return false;
}
void Function(void) {
  IsItOne(1);
  Exception_Depth(); // should be zero
}

To1ne avatar Sep 03 '13 15:09 To1ne

A possible solution might be to use a "smart object" on the stack, that will Exception_Dec() when it goes out of scope.

To1ne avatar Sep 03 '13 15:09 To1ne

This is a nasty one. Unfortunately such a smart object isn't possible in C but there may be other ways. Thanks, I'll have a think about it.

orangeduck avatar Sep 05 '13 10:09 orangeduck

Until I can think of a better solution I've simply added a warning to the website.

orangeduck avatar Sep 24 '13 13:09 orangeduck