Disallow null references in safe code?

Ary Borenszweig ary at esperanto.org.ar
Mon Feb 3 12:46:39 PST 2014


On 2/3/14, 5:56 AM, Walter Bright wrote:
> On 2/3/2014 12:00 AM, Uranuz wrote:
>> At the current state OS send SEGFAULT message and I can't
>> even get some info where is the source of problem.
>
> 1. Compile with symbolic debug info on (-g switch)
>
> 2. Run under a debugger, such as gdb
>
> 3. When it seg faults, type:
>
>     bt
>
> and it will give you a "backtrace", i.e. where it faulted, and the
> functions that are on the stack.

You keep missing the point that when the segfault happens you might have 
no idea how to reproduce it. You don't even know where it happens. So 
it's not that easy to reach point 3.

If a null access raises an exception, you immediately get the backtrace 
and that can help you understand why it happened.


More information about the Digitalmars-d mailing list