Preventing/handling space leaks

Fergus Henderson fjh at
Tue Dec 9 19:19:56 EST 2003

On 08-Dec-2003, ajb at <ajb at> wrote:
> G'day all.
> Quoting Sven Panne <Sven.Panne at>:
> > Granted, C++'s (copy) constructors, destructors and assignment operators
> > make some things relatively easy compared to C, but the complexity of
> > handling exceptions *correctly* makes things worse again: There is
> > a famous article (I can't remember the title or the author) where a
> > well-known C++ grandmaster explains a stack class, but another later
> > article by someone else describes the numerous bugs in that class when
> > exceptions are taken into account.
> Far be it from me to defend C++, but this problem is far better understood
> today than when that GoTW article (circa 1996, from memory) was written.

The problems are certainly better understood.  But they are also
certainly NOT understood well enough for programmers to be able to
reliably avoid them.

Even the C++ standard library itself, which has been
subject to review by the world's best C++ experts, suffers
from exception safety problems.  A new exception safety
problem with std::auto_ptr was discovered just last Friday!  See

Note that this class has already been the subject of extensive analysis
of its exception safety, and indeed the only reason that auto_ptr
was introduced in the first place was in an attempt to help guarantee
exception safety!

Fergus Henderson <fjh at>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <>  |     -- the last words of T. S. Garp.

More information about the Haskell-Cafe mailing list