NotNull pointers

David Nadlinger see at klickverbot.at
Wed Aug 31 14:32:22 PDT 2011


On 8/31/11 10:02 PM, Walter Bright wrote:
> On 8/31/2011 4:46 AM, Steven Schveighoffer wrote:
>> Seg faults are not as useful as asserts. It's a fact.
>
> You might be surprised, then, that I'll often temporarily replace an
> assert with a HLT instruction so I can use a debugger on it :-)

I am sure you have your reasons, because, well, you are Walter Bright, 
but wouldn't this rather be a testament of the inadequacy of the 
assert() implementation than an argument for – well, what is it exactly 
you are proposing? Using an assert solely for the segfault it causes as 
a side effect while the condition is evaluated?

All C++ implementations of assert() I have encountered so far provide a 
way of breaking on failing assertions if the program is being debugged: 
MSVC-compiled binaries display the »Abort/Retry/Ignore« dialog, and on 
Posix systems, the SIGABRT raised by abort() is usually caught by the 
debugger, causing it to break.

Have you considered following a similar approach for D? This could be 
implemented via a custom assert handler, but setAssertHandler has been 
deprecated in druntime commit fbbd2a7 (the commit message unfortunately 
doesn't mention a reason, IIRC because DMD doesn't generate a normal stack).

David


More information about the Digitalmars-d mailing list