Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-04-11 13:04:49

----- Original Message -----
From: <williamkempf_at_[hidden]>

> > It buys you the ability to take actions which may be more
> appropriate than
> > throwing an exception.
> void foo() throws(foobar)
> {
> ...
> }
> void bar()
> {
> try
> {
> foo();
> }
> catch(foobar)
> {
> // do alternate action deemed more appropriate than throwing
> }
> }
> You can always wrap to add exceptions or to remove exceptions. It's
> not a one side only thing.

Yes, but it's expensive, and now some unwinding actions have executed (the
ones to get out of foo()), so your program state is changed from the point
of detection. At the very least, all the same auto variables are no longer
available to a debugger.

> > > If you never call an empty function, you'll never get an
> > > exception.
> >
> > As I have previously posted, throwing an exception in place of an
> assertion
> > can make misuse much harder to debug. An assertion stops the
> program at the
> > point of the violation without changing its state, often producing
> a core
> > dump or other information which can be used to look at the program
> state in
> > a debugger. An exception causes stack unwinding and other reactions
> which
> > can obscure the cause of the problem.
> That is very much platform specific behavior.


> Under MS Windows I can
> debug exceptions _in exactly the same manner_ in which I debug
> assertions.

Actually I was specifically referring to JIT debugging on MS Windows. When
an assertion fires, stack unwinding will occur before you arrive in the
debugger - to prove it, print to cerr in the destructor of an auto variable
and assert (yes, there are workarounds for this).

> Some simple macros could allow this behavior to be true
> on all platforms regardless of built in support for JIT debugging of
> exceptions.
> > It comes down to a question of definitions: is passing a 0 to the
> > constructor misuse, or is it allowed? If it's misuse I want an
> assertion.
> Again, explain std::vector::at using this argument.

Why should I justify this function? I never would have written it into the
standard in the first place.

But anyway, using an invalid index with at() is allowed. That's the whole
point of at().


Boost list run by bdawes at, gregod at, cpdaniel at, john at