Boost logo

Boost :

From: E. Gladyshev (egladysh_at_[hidden])
Date: 2003-11-04 17:44:52


--- "E. Gladyshev" <egladysh_at_[hidden]> wrote:
>
> --- Peter Dimov <pdimov_at_[hidden]> wrote:
> [...]
> >
> > No. You _can_ have an incorrect program. It's just that exception safety
> > guarantees do not apply to it, but then again, no guarantees apply.
>
> Exactly, so in catch(...) blocks, you will be catching all exceptions
> including the ones that are generated by incorrect programs.
> So you cannot to assume that guarantees still apply in
> in catch(...) blocks?

Here is another example of an "expert article" on this issue.
This article *is* on practical (real-world) programming.

http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/

Take a look at the Solution 1: Brute Force
-------------
void User::AddFriend(User& newFriend)
{
    friends_.push_back(&newFriend);
    try
    {
        pDB_->AddFriend(GetName(), newFriend.GetName());
    }
    catch (...)
    {
        friends_.pop_back();
        throw;
    }
}
[...]
"you catch the exception (no matter what it is), you undo the push_back operation with a call to
vector::pop_back, and you nicely re-throw the exact same exception."

--------------

No mention about the serious catch(...)
issues on real systems.
It is just terrible. Imagine how many people
are going to read this article and use
this technique because from the description,
it might work just fine for them and they
assume the authors are the experts.
I am sure the authors are experts but sorry,
in this case, they just weren't very responsible
to the readers.
The weird thing is that this particular ignorance
(on the exception issue) seems to be an epidemic
in the respected community.

BTW: I just bought a book of one the authors. :)
Seems to be a good book, quite compact.

Eugene

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk