The library distinction
```c void *memcpy(void *restrict s1, const void *restrict s2, size_t n); void *memmove(void *s1, const void *s2, size_t n); ``` `memcpy` requires the objects accessed through `s1` and `s2` not to overlap. `memmove` makes no such assumption and therefore accepts overlapping objects, potentially with less opportunity for optimization. TAKEAWAY: `restrict` promises exclusive access through a pointer; the caller must ensure that promise holds. section 15.2
`restrict` is a qualifier for pointer types. It tells the compiler that, during the relevant computation, the qualified pointer provides the exclusive access to the object it points to. The object must not also be accessed through an alias handled by the compiler. This can enable optimization, but the declaration constrains the caller rather than enforcing the property for them. section 15.2 section 15.4
Apply the rule carefully at function boundaries:
- Treat two restrict-qualified parameters as requiring separate, non-overlapping access when the function execution uses both. section 15.2
- Check variadic calls as well: a format pointer must not alias arguments passed through the `...` portion of `printf`-family functions. section 15.2
- Do not assume a legal cast removes the obligation; accessing the same object through another pointer can still violate the restriction. section 15.2
- Measure claimed gains rather than relying on the qualifier alone, because incorrect use trades correctness for an optimization opportunity. section 15.4
1 void* memcpy(void*restrict s1, void const*restrict s2, size_t n);
2 void* memmove(void* s1, const void* s2, size_t n);
!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":1}],[{\"line\":1,\"ch\":25},{\"line\":1,\"ch\":26}],[{\"line\":0,\"ch\":4},{\"line\":0,\"ch\":8}],[{\"line\":1,\"ch\":4},{\"line\":1,\"ch\":8}],[{\"line\":0,\"ch\":10},{\"line\":0,\"ch\":16}],[{\"line\":0,\"ch\":4},{\"line\":0,\"ch\":8}],[{\"line\":1,\"ch\":4},{\"line\":1,\"ch\":8}],[{\"line\":0,\"ch\":22},{\"line\":0,\"ch\":30}],[{\"line\":0,\"ch\":35},{\"line\":0,\"ch\":45}],[{\"line\":0,\"ch\":22},{\"line\":0,\"ch\":30}],[{\"line\":0,\"ch\":60},{\"line\":0,\"ch\":66}],[{\"line\":1,\"ch\":44},{\"line\":1,\"ch\":50}],[{\"line\":0,\"ch\":56},{\"line\":0,\"ch\":57}],[{\"line\":1,\"ch\":0},{\"line\":1,\"ch\":1}],[{\"line\":0,\"ch\":4},{\"line\":0,\"ch\":8}],[{\"line\":1,\"ch\":4},{\"line\":1,\"ch\":8}],[{\"line\":1,\"ch\":10},{\"line\":1,\"ch\":17}],[{\"line\":0,\"ch\":4},{\"line\":0,\"ch\":8}],[{\"line\":1,\"ch\":4},{\"line\":1,\"ch\":8}],[{\"line\":1,\"ch\":28},{\"line\":1,\"ch\":38}],[{\"line\":0,\"ch\":60},{\"line\":0,\"ch\":66}],[{\"line\":1,\"ch\":44},{\"line\":1,\"ch\":50}]]"}
!@%STYLE%@!
Compare the declarations of `memcpy` and `memmove` directly to see where exclusive-access assumptions appear in an interface. section 15.2

