The restrict Keyword
The Numerical C Extensions Group X3J11.1 proposed (1993) a restrict keyword as the way to specify pointer access models.
The restrict semantics:
- assume de-referencing the qualified pointer is the only way the program can access the memory pointed to by that pointer
- loads and stores through such a pointer do not alias with any other load and stores, except these with the same pointer
-
-
-
-
-
-
-
- in this example, it is sufficient to indicate restrict b, since it is necessary to qualify only the pointers being stored through
- to enable the restrict keyword it is necessary to use the compiler flag (7.2 and 7.3 compilers): -LANG:restrict
void copy(double * restrict a,
double * restrict b, int n)
for(i=1; i<n; i++) b[i] = a[i];