Exception isn't thrown as expected

Marco Leise Marco.Leise at gmx.de
Fri May 31 10:46:13 PDT 2013


Am Fri, 31 May 2013 10:59:09 +0700
schrieb Alexandr Druzhinin <drug2004 at bk.ru>:

> You mean I didn't initialize c?

It was a wild guess, that you might come from C++ and write

  SomeClass c;

which would be an instance of that class in C++, but a null
reference in D. As you said you only get the hanging when you
compare the this.data_ field with null it could have made some
sense.

> If even so, it should throw an 
> exception, no hanging, I think. Nevertheless, a class instance is 
> correct. I'll try to reduce code.

Others may know for sure, but I think D only throws
NullPointerExceptions in @safe code and leaves it to the
operating system to stop your program in other cases. So on
Linux it would SEGFAULT and on Windows you probably get a
message box. But yeah... that still doesn't explain the
hanging :D

-- 
Marco



More information about the Digitalmars-d-learn mailing list