Pointer aliasing in D (Was: Programming language benchmarks)

Jens Mueller jens.k.mueller at gmx.de
Thu Apr 28 14:44:13 PDT 2011


Timon Gehr wrote:
> > 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
> 
> assert(p1 != p2); (or assert(c1 !is c2) for references).
> 
> I do not think DMD takes advantage of such constructs yet though.

Just because the pointers aren't equal doesn't mean that they won't
alias. So I don't see how the above can help. As far as I understand it
the compiler has to know at compile time that the given pointers won't
alias.

Jens


More information about the Digitalmars-d mailing list