Negative
Walter Bright
newshound at digitalmars.com
Tue Feb 28 01:58:32 PST 2006
"Andrew Fedoniouk" <news at terrainformatica.com> wrote in message
news:du106f$ptt$1 at digitaldaemon.com...
> Well, I spent year programming on PocketPC in eVC where are no such
> things as exceptions. In principle. Not implemented in C++ compiler.
> Still alive :)
It's true that if code doesn't generate exceptions, then one doesn't need
exception safety.
> But
> Transaction abc()
> {
> try {
> Foo f = dofoo();
> Bar b = dobar();
> Def d = dodef();
> return Transaction(f, b, d);
> } catch(object er) {
> delete f; delete b; delete d;
> }
> }
> is not worse to be honest.
It is worse because it won't even compile. f, b, and d are not in scope in
the catch statement. Even if they were, there's still a serious bug - if
dofoo() throws an exception, then the catch statement will attempt to delete
b and d, which are not even initialized yet.
More information about the Digitalmars-d
mailing list