Negative
Walter Bright
newshound at digitalmars.com
Tue Feb 28 10:08:26 PST 2006
"Sean Kelly" <sean at f4.ca> wrote in message
news:du225a$2549$1 at digitaldaemon.com...
>>> 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.
>
> Is it really a bug to call delete on a null reference? This is
> well-defined behavior in C++.
It's not even a null reference.
More information about the Digitalmars-d
mailing list