Null pointer dereferencing in D

Maxim Fomin via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 14 10:44:57 PDT 2014


On Saturday, 14 June 2014 at 17:05:21 UTC, David Nadlinger wrote:
> On Saturday, 14 June 2014 at 16:45:19 UTC, Maxim Fomin wrote:
>> The case which you described is a not a type safety problem.
>
> If a struct type has a non-trivial invariant(), .init allows an 
> object to exist that violates it without an Error being thrown.
>
> Arguing that this is not part of the type system would be 
> splitting hairs.
>
> David

Again, it may depend on your definition of type safety. In my 
view, it is not related. It is a problem of unwarranted 
assumption about data correctness in a system level language.

By the way, AFAIK the issue has been already filed in bugzilla 
(closed as wontfix) and discussed in newsgroups. After the 
discussion the spec was updated to explicitly mention that init 
property may be problematic http://dlang.org/property.html 
(please notice, that invariant example is in the spec). Another 
issue which popped up is that in order to fix disable this() init 
problem, one need to break assumption about init availability in 
compile time, which breaks CTFE. In other words, it is impossible 
to fix the issue without creating a multitude of new problems.


More information about the Digitalmars-d mailing list