www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - pointer aliasing in D


Are there some pointer-aliasing contraints in D? Is there maybe some
similar like strict-aliasing in C?

Consider the following program:

struct S {
        int i;
struct T {
        int i;
void bar(S *a, T *b, S *c)
        b.i = a.i;
        c.i = a.i;

Since a and b are pointers of different types, a C compiler is allowed
to cache a.i in a register (the store to b.i must no change a.i).
Jan 15 2007