D Exceptions

Steve Teale steve.teale at britseyeview.com
Tue Jan 26 08:07:11 PST 2010


If I have a program like:

import std.stdio;
void main()
{
    try
    {
         char* p = cast(char*) 1234;
         *p = '?';
    }
    catch (Exception x)     // same story with Exception or Error
    {
        writefln("Caught Exception");
    }
}

If I build and run in in Linux, with either DMD 1.055 or the current GDC, the program quits with a Segmentation fault message. Under Windows (and I am running an old D2 there), it says:

object.Error: Access Violation

Which looks like a message from D. If I write a D Linux program that just throws an exception, then it says:

Error: My exception message

Which is clearly a message from D.

So it seems there is a safety net in Windows, but not in Linux. Is this how it is supposed to be?



More information about the Digitalmars-d mailing list