C/C++ style Crashes?

Alexander Panek a.panek at brainsware.org
Fri Jan 12 00:48:50 PST 2007


Sebastian Biallas wrote:
> Jon Grant wrote:
>> Hi
>> Just having a look at the D language.
>> Does D still let the programmer allocate memory, cast addresses and read/write
>> direct address space as we can from C/C++?
>>
>> I'd like to know if it solves this problem, Java and C# don't allow such access.
> 
> An important point is that this doesn't solve this problem either. Ok,
> you get an exception instead of some "undefined behaviour", which is
> somehow better when debugging, but:
> 
> It just doen't solve the problem that you have a bug in your program in
> the first place. Reread that sentence.

Exceptions can be handled at runtime, still. try (to) catch it and there 
you go. :)

> 
> Getting an unexpected exception in a shipped application is a huge bug.

That's why you always /test/ everything so good, that you just don't get 
unexpected exceptions.

> In fact it can be:
> 
> *) a security risc: the program is taking a path of execution the
> programmer haven't thought of.
> *) a security risc2: some data might be in a undefined state after the
> exception
> *) a data risc: the program might be in an undefined state. Saving now,
> might save garbage.
> 
> [As you might have noticed, these are exactly the problem you have with
> C, C++ and D]
> 
> And, even worse, not only that Java doesn't help you getting the
> exception handlers right in the code, it doesn't help you avoiding
> exceptions in the first place (it getting better with the template types
> (don't know how they call it)).

What's the huge problem with exception handlers? They worked for me 
pretty well so far to avoid a unhandled exceptions that just terminate 
the program.



More information about the Digitalmars-d mailing list