From: Ted Byers (r.ted.byers_at_[hidden])
Date: 2002-06-14 21:11:46
"David Abrahams" <david.abrahams_at_[hidden]> wrote in message
> ----- Original Message -----
> From: "Fernando Cacciola" <fcacciola_at_[hidden]>
> > ----- Original Message -----
> > From: "David Abrahams" <david.abrahams_at_[hidden]>
> > > I just want to point out that the termination model used by C++
> > > makes any approach using them unsuitable for a great many
> > >
> > > -Dave
> > >
> > I don't understand what you mean. Could you elaborate it?
> Exceptions cause unwinding. Often you don't want that.
> Example 1: assertions. By the time the stack is unwound much information
> lost. On Unix, for example, you want a core dump, not an exception. On
> Windows you also don't want stack unwinding, though the case is a little
> more complicated there.
What I would be inclined to do with assertions is collect as much
information as I can at the point where the assertion failed: presumably, a
clever programmer could capture this information that would be lost by the
time the stack is unwound. I'd have to rely on someone like you to tell me
how to capture that information, and then I'd package it in one of my
traceable exceptions which can then give me my trace information.
> Example 2: memory allocation tracking and leak detection. An extremely
> useful technique involves labeling each allocated block with the call
> leading to the allocation. If every allocation causes an exception, your
> program won't get far.
The sort of bug that could give me nightmares is that where a nasty bit of
code trashes memory owned by an instance of one of my classes, causing
working code wholly unrelated to the real bug to crash at some random time
after the real error has occured. I am sensitive to leaks of any kind of
leak, having just fixed a major memory leak earlier this week. While this
is something of a change in topic, are there any tools, utility classes, or
anything that can facilitate detecting and fixing leaks, and, equally
importantly, invalid access to resources of any kind?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk