safety: null checks

Dibyendu Majumdar mobile at majumdar.org.uk
Mon Nov 23 17:27:14 UTC 2020


On Monday, 23 November 2020 at 17:17:26 UTC, Paul Backus wrote:
> On Monday, 23 November 2020 at 16:50:44 UTC, Johan Engelen 
> wrote:
>> On Monday, 23 November 2020 at 12:03:49 UTC, Paul Backus wrote:
>>>
>>> Then LDC allows memory corruption in @safe code,
>>
>> Correct. And so do all other D compilers. Completely 
>> independent of optimization level.
>>
>>> which is a bug.
>>
>> Without explicit null pointer checking, this is effectively a 
>> "won't fix".
>
> Maybe it is for LDC. I suspect Walter puts a high enough 
> priority on memory-safety that he would accept a fix for this 
> issue into DMD.

Hi,

I think it is not fixable without introducing severe penalty in 
performance I suspect. Some languages are adding features to help 
the compiler / user specicify where nulls can be expected. Maybe 
D needs this too.

My original issue was that it failed to check an obvious case.
It seems that DMD does detect that case when -O is used. But that 
is perhaps not great.

Other languages - even C or C+= these days, will immediately warn 
you about possible NULL de-reference when it is very obvious.


More information about the Digitalmars-d mailing list