Disallow null references in safe code?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Feb 2 19:49:21 PST 2014


On 2/2/14, 5:47 PM, deadalnix wrote:
> On Sunday, 2 February 2014 at 23:55:48 UTC, Andrei Alexandrescu wrote:
>> On 2/2/14, 3:44 PM, Timon Gehr wrote:
>>> On 02/03/2014 12:09 AM, Andrei Alexandrescu wrote:
>>>>
>>>> A front-end pass could replace the dead dereference with a guard that
>>>> asserts the reference is not null.
>>>
>>> I don't think this would be feasible. (The front-end pass would need to
>>> simulate all back-end passes in order to find all the references that
>>> might be proven dead.)
>>
>> Well I was thinking of a backend-specific assertion directive. Worst
>> case, the front end could assign to a volatile global:
>>
>> __vglobal = *p;
>>
>>
>> Andrei
>
> As far as the backend is concerned, dereferencing and assigning to a
> volatile are 2 distinct operations.

No matter. The point is the dereference will not be dead to the optimizer.

Andrei


More information about the Digitalmars-d mailing list