4.73 Restricted pointers in C99

The C99 keyword restrict is an indication to the compiler that different object pointer types and function parameter arrays do not point to overlapping regions of memory.

This enables the compiler to perform optimizations that might otherwise be prevented because of possible aliasing.
In the following example, pointer a does not, and must not, point to the same region of memory as pointer b:
void copy_array(int n, int *restrict a, int *restrict b)
    while (n-- > 0)
        *a++ = *b++;
void test(void)
    extern int array[100];
    copy_array(50, array + 50, array);    // valid
    copy_array(50, array + 1, array);     // undefined behavior
Pointers qualified with restrict can however point to different arrays, or to different regions within an array.
It is your responsibility to ensure that restrict-qualified pointers do not point to overlapping regions of memory.
__restrict, permitted in C90 and C++, is a synonym for restrict.
--restrict enables restrict to be used in C90 and C++.
Related concepts
4.59 New language features of C99
4.61 // comments in C99 and C90
4.62 Compound literals in C99
4.63 Designated initializers in C99
4.64 Hexadecimal floating-point numbers in C99
4.65 Flexible array members in C99
4.66 __func__ predefined identifier in C99
4.67 inline functions in C99
4.68 long long data type in C99 and C90
4.69 Macros with a variable number of arguments in C99
4.70 Mixed declarations and statements in C99
4.71 New block scopes for selection and iteration statements in C99
4.72 _Pragma preprocessing operator in C99
4.75 Complex numbers in C99
Related reference
7.145 --restrict, --no_restrict
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.