Pointer aliasing in D (Was: Programming language benchmarks)

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Apr 28 17:30:42 PDT 2011


On 4/28/11 4:14 PM, Jens Mueller wrote:
> Walter Bright wrote:
>> On 4/28/2011 11:44 AM, Jens Mueller wrote:
>>> Thanks. So if a compiler can assume that pointers do not alias it can
>>> generate much better code. What's D's standpoint on that matter then?
>>> C99 has restrict. I never came across something similar in D.
>>
>> Const and immutable.
>>
>
> That allows specifying that the memory pointed to is only readable which
> enables doing the optimizations. But what if the memory is writable but
> I can my sure that the pointers pointing to it will never alias? How do
> I pass that information to the compiler?
>
> Jens

There is no way. I don't know of a language where that is possible in a 
systematic and provable way. C's restricts sets a poor example.

Andrei


More information about the Digitalmars-d mailing list