Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-796

Only escape sequences defined in the ISO C standard should be used

    Details

    • Type: Bug Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way
    • Legacy Key:
      InvalidEscapeSequence
    • Covered Languages:
      C, C++, Objective-C
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • MISRA C 2004:
      4.1
    • MISRA C++ 2008:
      2-13-1
    • PC-Lint:
      606, 1606

      Description

      The use of an undefined escape sequence leads to undefined behavior. The defined escape sequences (ISO/IEC 14882:2003 [1] ยง2.13.2) are: \n, \t, \v, \b, \r, \f, \a,
      }}, {{?
      , \', \", \<Octal Number>, and \x<Hexadecimal Number>.

      Noncompliant Code Example

      const char_t a[ 2 ] = "\k";   // Noncompliant
      const char_t b[ 2 ] = "\b";   // Compliant
      

      See

      • MISRA C:2004, 4.1 - Only those escape sequences that are defined in ISO C standard shall be used.
      • MISRA C++:2008, 2-13-1 - Only those escape sequences that are defined in ISO/IEC 14882:2003 shall be used.

        Attachments

          Issue Links

          1.
          C-Family RSPEC-4384 Language-Specification Active Unassigned

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Anonymous
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated: