Topic: exceptions, unexpected() and muddle_on()


Author: spuler@coral.cs.jcu.edu.au (David Spuler)
Date: 14 Dec 92 20:06:44 GMT
Raw View
On page 320, Stroustrup, 2nd edition, declares the function

void muddle_on() { cerr << "muddling on\n";  }

and installs it so as to be called by unexpected().

My question is: what happens if a function installed by set_unexpected returns?
Stroustrup says

"This will cause a normal return from a function detecting an unexpected
exception. .... "

I don't see how this can happen.
Does the throw expression return and execution continue from there??
(Seems not since this could be way down deep in the stack.)
Or does the function which raised the unexpected exception just return with a
garbage return value?

The ARM seems to have nothing to say about set_unexpected functions returning.

Any insight appreciated,
David Spuler




Author: jss@lucid.com (Jerry Schwarz)
Date: Tue, 15 Dec 92 01:23:51 GMT
Raw View
In article <spuler.724363604@coral>, spuler@coral.cs.jcu.edu.au (David Spuler) writes:
|>
|> My question is: what happens if a function installed by set_unexpected returns?
|> Stroustrup says
|>
|> "This will cause a normal return from a function detecting an unexpected
|> exception. .... "
|>

The current x3j16/sc22 working paper says "The unexpected() function
[i.e. the one set by set_unexpected] may not return, but it may throw
an exception. Handlers for the exception will be looked for starting
at the call of the function whose exception-specification was violated."

Thus the answer to the question is: undefined.

   -- Jerry Schwarz