D - Unsafe and doomed

Walter Bright newshound2 at digitalmars.com
Mon Jan 6 19:18:02 PST 2014


On 1/6/2014 4:13 PM, deadalnix wrote:
> On Monday, 6 January 2014 at 21:09:44 UTC, Walter Bright wrote:
>> On 1/6/2014 1:03 PM, Walter Bright wrote:
>>> On 1/6/2014 11:21 AM, deadalnix wrote:
>>>> Or, we can decide that trapping in not guaranteed, and then dereferencing null
>>>> is undefined behavior,
>>>> which is much worse that a compile time failure.
>>>
>>> Realistically, this is a non-problem.
>>
>> Or better, if you want to issue a pull request for the documentation that says
>> unless it is a dead load, a null reference will cause a program-ending fault
>> of one sort or another, I'll back it.
>
> You realize that every
>
> foo.bar();
>
> is undefined behavior unless it is preceded by a null check under that definition ?

No, I don't realize that.

Or you could amend the documentation to say that null checks will not be removed 
even if they occur after a dereference.


More information about the Digitalmars-d mailing list