Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)

Timon Gehr timon.gehr at gmx.ch
Sun May 19 17:46:44 PDT 2013


On 05/20/2013 01:39 AM, Andrei Alexandrescu wrote:
> On 5/19/13 7:06 PM, deadalnix wrote:
>> On Sunday, 19 May 2013 at 22:32:58 UTC, Andrei Alexandrescu wrote:
>>> How was there a bug if everything was properly synchronized? You
>>> either describe the matter with sufficient detail, or acknowledge the
>>> destruction of your anecdote. This is going nowhere.
>>>
>>
>> I explained over and over. A field is initialized to null, while the
>> object lock is owned, and later to its value, while it is locked. In the
>> meantime, another thread access the object, owning the lock, assuming
>> the field is always initialized.
>
> How does another thread thread accesses the object "owning the lock"
> when the assignment occurs under lock?
>

lock{ initialize to null. }
lock{ in the meantime assume correctly initialized. }
lock{ initialize correctly. }

This is nothing new. I think he has been pretty clear about what the 
issue is from the beginning.

> How would non-null fix this? Would the object have type Maybe?
>

This is one possibility. In this case, the type system would have 
prevented the null dereference.
In the other case, the type system would have caught the invalid 
initialization.


More information about the Digitalmars-d mailing list