I came across these two sections in C11 standard referring to the restrict qualifier:
1#
6.7.3-8
An object that is accessed through a restrict-qualified pointer has a
special association with that pointer. This association, defined in
6.7.3.1 below, requires that all accesses to that object use, directly or indirectly, the value of that particular pointer.135) The intended
use of the restrict qualifier (like the register storage class) is to
promote optimization, and deleting all instances of the qualifier
from all preprocessing translation units composing a conforming
program does not change its meaning (i.e., observable behavior).
Can you explain me the meaning of the cursive fragment? In my interpretation, since it doesn’t change its meaning, it looks like that the using of restrict is just pointless…
2#
6.7.3.1-6
A translator is free to ignore any or all aliasing implications of
uses of restrict.
What might these aliasing implications be? Can you show me some examples?
The cursive statement in the first quote basically said:
#define restrictline into your code without changing any meaning of your c-code. You code may become a bit slower due to missed optimization, but you will in all cases get the same, deterministic results as if you would have used the restrict keyword.Second paragraph means that the compiler is free to ignore the restrict keyword. Easy as that.