It's worth mentioning that for some reason, Solaris doesn't protect the entire 
first page of memory--only the zero address. For accesses the where the 
compiler pre-computes the offset and reads that location directly, you won't 
get a segfault if the pointer is null (at least with GCC--haven't tested with 
Sun's compiler). This makes no sense to me and it's been the source of a ton of 
problems in C apps I've found. I'm just mentioning this because it's made me 
leery of relying on the hardware to flag null accesses. 

Sent from my iPhone

On Aug 30, 2011, at 4:19 PM, Walter Bright <[email protected]> wrote:

> 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.
> 

Reply via email to