Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A restrict-qualified pointer is assigned a value based on another restricted pointer whose associated block neither began execution before the block associated with this pointer, nor ended before the assignment (6.7.3.1).

...

The function g() declares an array d consisting of 100 int values and then invokes f() to copy memory from one area of the array to another. This call has undefined behavior because each of d[1] through d[49] is accessed through both p and q.

...

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 to f() in g() is valid because the storage allocated to d is effectively divided into two disjoint objects.

...

Ensure that restrict-qualified source and destination pointers do not reference overlapping objects when invoking library functions. For example, the following table lists C Standard standard library functions that copy memory from a source object referenced by a restrict-qualified pointer to a destination object that is also referenced by a restrict-qualified pointer: 

...

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

EXP43-C

Medium

Probable

High

P4

L3

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

...

Tool

Version

Checker

Description

LDRA tool suite

Include Page
LDRA_V
LDRA_V

480 S, 489 S, 613 S

Enhanced Enforcementenforcement
PRQA QA-C
Include Page
PRQA QA-C_v
PRQA QA-C_v
3314 
SonarQube Plugin
Include Page
SonarQube_V
SonarQube_V
S1836Implements MISRA C:2012 Rule 8.14

...

  1. MISRA Rule 8.14 prohibits the use of the restrict keyword except in C Standard Library Functionsstandard library functions

Bibliography

[ISO/IEC 9899:2011]6.7.3.1, "Formal Definition of restrict
[Walls 2006] 

...