Main Content

MISRA C:2012 Rule 8.14

The restrict type qualifier shall not be used

Description

Rule Definition

The restrict type qualifier shall not be used.

Rationale

When you use a restrict qualifier carefully, it improves the efficiency of code generated by a compiler. It can also improve static analysis. However, when using the restrict qualifier, it is difficult to make sure that the memory areas operated on by two or more pointers do not overlap.

Polyspace Implementation

The rule checker flags all uses of the restrict qualifier.

Troubleshooting

If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.

Examples

expand all

void f(int n, int * restrict p, int * restrict q)/*Noncompliant*/ 
{
}

In this example, both uses of the restrict qualifier are flagged.

Check Information

Group: Declarations and Definitions
Category: Required
AGC Category: Advisory

Version History

Introduced in R2014b