Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Message:
      Remove this use of the "restrict" type qualifier.
    • Default Severity:
      Critical
    • Impact:
      High
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way
    • Covered Languages:
      C, Objective-C
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      10min
    • CERT:
      EXP43-C.
    • MISRA C 2012:
      8.14

      Description

      The restrict type qualifier is a guarantee by the programmer that there are no other pointers with access to the referenced object, and that the object does not overlap with any other object in memory. Its use may allow the compiler to generate more efficient byte code.

      However, this is a tricky language feature to use correctly, and there is significant risk of unexpected program behavior if restrict is misused. Therefore, restrict should not be used.

      Noncompliant Code Example

      void user_copy (
        void * restrict p,  // Noncompliant parameter
        void * restrict q,  // Noncompliant parameter
        size_t n
      ) {
        // ...
      }
      

      See

      • MISRA C:2012, 8.14 - The restrict type qualifier shall not be used
      • CERT, EXP43-C. - Avoid undefined behavior when using restrict-qualified pointers

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ann.campbell.2 Ann Campbell
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: