Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

MISRA.TYPE.RESTRICT.QUAL.2012

The restrict type qualifier shall not be used.

MISRA C 2012 Rule 8.14: The restrict type qualifier shall not be used

C99 [Undefined 65, 66]

Category: Required

Analysis: Decidable, Single Translation Unit

Applies to: C99

Rationale

When used with care the restrict type qualifier may improve the efficiency of code generated by a compiler. It may also allow improved static analysis. However, to use the restrict type qualifier the programmer must be sure that the memory areas operated on by two or more pointers do not overlap.

There is a significant risk that a compiler will generate code that does not behave as expected if restrict is used incorrectly.

Example

The following example is compliant because the MISRA C Guidelines do not apply to The Standard Library functions. The programmer must ensure that the areas defined by p, q and n do not overlap.

        #include <string.h>
void f ( void ) 
{
  /* memcpy has restrict-qualified parameters */ 
  memcpy ( p, q, n ); 
}

The following example is non-compliant because a function has been defined using restrict.

void user_copy ( void * restrict p, void * restrict q, size_t n ) 
{ 
}