C/C++ style Crashes?

Sebastian Biallas groups.5.sepp at spamgourmet.com
Thu Jan 11 19:15:42 PST 2007


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.

Getting an unexpected exception in a shipped application is a huge bug.
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)).



More information about the Digitalmars-d mailing list