NotNull pointers

Walter Bright newshound2 at digitalmars.com
Tue Aug 30 16:19:00 PDT 2011


On 8/30/2011 4:07 PM, Timon Gehr wrote:
> You mean, in release mode the assert gets compiled out, and it seg faults in the
> code sequence that depends on the assertion, right?

Yes. Any dereference of a null class ref would cause a seg fault.

> I am not afraid of seg faults so much, but in debug mode it is certainly an
> annoyance, because you don't get the source line and stack trace. I'd say it
> would be really nice if assert(classreference); would never seg fault during
> debugging.

Why? I rely on that for debugging. I run it under the debugger, seg fault, bing 
the debugger shows where it faulted and a stack trace. It's about 98% of what a 
debugger is good for.

Andrei will reply that there are some environments where you cannot use a 
debugger, and he's right. But there are other workarounds for that - D doesn't 
*prevent* you from doing soft debugging.


> Is there any practical use for manually running the class invariant?

Looking for corruption of the data.



More information about the Digitalmars-d mailing list