Negative

Sean Kelly sean at f4.ca
Tue Feb 28 09:44:09 PST 2006


Walter Bright wrote:
> "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.

It's worth mentioning that an allocation failure will cause an exception 
to be thrown, in addition to divide by zero and other errors on Windows. 
  So code doesn't need to explicitly throw to generate exceptions.

The PocketPC really doesn't have exceptions?  And they still call it 
C++? :-)

>> 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++.


Sean



More information about the Digitalmars-d mailing list