P
pemo
In Harbison and Steele's book, they say that using 'restrict' allows
functions like memcpy() to be prototyped like this:
void * memcpy(void * restrict s1, const void * restrict s2, size_t n);
But this seems a mite dangerous to me ... a restricted pointer ... is
*assumed* to be the only to access an object.
So, mightn't using such a prototype subtly imply [to some] that the compiler
will *actively check* [completely!] that s1 and s2 do not point to the same
object [or that s1/s2's memory does not overlap]? It couldn't do this
[IMHO] without adding code to check, and thus impacting the very thing that
restrict is meant to aid - optimisation.
If the prototype should be read/interpreted as 'don't let s1 and s2 have the
same value' [or overlap], is using a prototype like this simply a way of
documenting this?
functions like memcpy() to be prototyped like this:
void * memcpy(void * restrict s1, const void * restrict s2, size_t n);
But this seems a mite dangerous to me ... a restricted pointer ... is
*assumed* to be the only to access an object.
So, mightn't using such a prototype subtly imply [to some] that the compiler
will *actively check* [completely!] that s1 and s2 do not point to the same
object [or that s1/s2's memory does not overlap]? It couldn't do this
[IMHO] without adding code to check, and thus impacting the very thing that
restrict is meant to aid - optimisation.
If the prototype should be read/interpreted as 'don't let s1 and s2 have the
same value' [or overlap], is using a prototype like this simply a way of
documenting this?