Topic: is 15.1/8 reasonable?
Author: Gene Bushuyev <gbush@deja.com>
Date: Tue, 12 Dec 2000 14:47:00 GMT Raw View
15.1/8 defines throw-expression without operand as calling terminate() if
no exception is presently being handled. That seems to be counter intuitive.
Nothing prevents a function to be an error handler and rethrowing the
exception that it handles. But imagine that the same function was called
when no exception was thrown; oops - program crashes with terminate(). I
think simple logic requires throw to have no action in this case. If I
wanted to have terminate I would have called terminate() - not throw.
Can anybody elucidate this case for me?
Gene Bushuyev
--
--------------------
"I did not invent Internet"(me)
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: Ron Natalie <ron@sensor.com>
Date: Tue, 12 Dec 2000 14:56:25 GMT Raw View
Gene Bushuyev wrote:
>
> 15.1/8 defines throw-expression without operand as calling terminate() if
> no exception is presently being handled. That seems to be counter intuitive.
> Nothing prevents a function to be an error handler and rethrowing the
> exception that it handles. But imagine that the same function was called
> when no exception was thrown; oops - program crashes with terminate(). I
> think simple logic requires throw to have no action in this case. If I
> wanted to have terminate I would have called terminate() - not throw.
> Can anybody elucidate this case for me?
Yes, attempting to rethrow when no exception is being handled is an error.
The programmer should not have allowed it to happen. The obvious solutions
to the problem are to call terminate() (the general way the language bails
when faced with insurmountable problems in exceptions), or to just leave
the behavior undefined (not very gratifying).
Your solution is terrible. You don't expect flow to continue past
a throw EVER. It's sort of like having the "exit(0)" routine return
(believe me I've been through that nightmare, ExitThread sometimes
returns in Windows, ugh puke). Why would you want it to just continue?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]