Understand the `restrict` keyword in C99
Introduction
What problem does restrict solve?
Another example with SVE2
When can you use restrict
Next Steps
Understand the `restrict` keyword in C99
Review frequently asked questions
These FAQs were drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
Use
restrict when the memory regions referenced by the pointer parameters don’t overlap and the function has no other access path to those regions. If any argument can alias another, don’t use restrict.The compiler can assume no aliasing and might generate vectorized code. On Arm with SVE2, look for vector registers (
z0–z31) and predicated operations in the assembly.If one pointer argument derives from another, such as a pointer into the same array, the regions overlap. Passing those pointers to a
restrict-qualified function violates its contract.Inspect the generated assembly for SVE2 instructions and vector registers.
whilelo predicates and ld1b or st1b instructions with z registers indicate SVE2 code generation.Avoid
restrict if the function can reach the same memory through another alias, such as a global pointer or indirect access. The non-aliasing guarantee must hold throughout the function.