As far as I understand the formal definition of "restrict" in section 6.7.3.1 of the C standard,
in the function below, pointer y
is based on a restrict
pointer x
; hence, the compiler will assume that accesses *x
and *y
might alias:
void assign1(int *pA, long N) {
int *restrict x = pA;
{
int *y = x + N;
*x = *y;
}
}
However, what if y
itself is declared restrict
: can the compiler assume that *x
and *y
will never alias?
void assign2(int *pA, long N) {
int *restrict x = pA;
{
int *restrict y = x + N;
*x = *y;
}
}