<div dir="ltr">We recently found an issue when using the full restrict implementation developed by Jeroen; it surfaces when compiling an obscure combination of std::valarray and std::indirect_array but I don't want to bore you with all the details. What it boils down to is this basic question about restrict:<br><br>Given one restrict pointer based on another, should they never alias?<br><br>As far as I understand the formal definition of "restrict" in section 6.7.3.1 of the C standard [1], in the function below, pointer `y` is based on "restrict" pointer `x`; hence, the compiler will assume that accesses *x and *y might alias:<br><br><font size="4"><span style="font-family:monospace">void assign1(int *pA, long N) {<br>  int *restrict x = pA;<br>  {<br>    int *y = x + N;<br>    *x = *y;<br>  }<br>}</span></font><br><br><br>However, what if y itself is declared "restrict": can the compiler assume that *x and *y will never alias?<br><br><font size="4"><span style="font-family:monospace">void assign2(int *pA, long N) {<br>  int *restrict x = pA;<br>  {<br>    int *restrict y = x + N;<br>    *x = *y;<br>  }<br>}</span></font><br><br>Both Jeroen's and Hal's implementation (the intrinsic-based one) will say "NoAlias" for the accesses in assign2() but shouldn't x and y be in the same restrictness "bucket" since y is based on x?<br><br>[1] <a href="http://port70.net/~nsz/c/c11/n1570.html#6.7.3.1">http://port70.net/~nsz/c/c11/n1570.html#6.7.3.1</a></div>