Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: in progress

...

In this compliant solution, the function f() is unchanged but the programmer has ensured that none of the calls to f() result in undefined behavior.  The call of f() in g() is valid because the storage is allocated to d is effectively subdivided into two disjoint objects.

Code Block
bgColor#ccccff
langc
void f(int n, int * restrict p, int * restrict q) {
   while (n-- > 0)
     *p++ = *q++; 
}
 
void g(void) {
   extern int d[100];

  /* ... */
  f(50, d + 50, d); //*  valid */
}

Invoking Library Functions with restrict-qualified Pointers

...