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.TOKEN.WRONGESC

Incorrect escape sequence in a literal.

MISRA-C Rule 4.1 (required): Only those escape sequences that are defined in the ISO C standard shall be used.

[Undefined 11; Implementation 11]

Only "simple-escape-sequences" in ISO/IEC 9899:1990 [3—6] Section 6.1.3.4 and '\0' are permitted escape sequences.

All "hexadecimal-escape-sequences" are prohibited.

The "octal-escape-sequences" other than '\0' are also prohibited under Rule 7.1.

MISRA-C++ Rule 2-13-1 (required): Only those escape sequences that are defined in ISO/IEC 14882:2003 shall be used.

[Undefined 2.13.2(3)]

Rationale

The use of an undefined escape sequence leads to undefined behaviour.

The defined escape sequences (ISO/IEC 14882:2003 [1] §2.13.2) are:

\n, \t, \v, \b, \r, \f, \a, \\, \?, \', \", \<Octal Number>, \x<Hexadecimal Number>

Example

void fn ( )
{
   const char_t a[ 2 ] = "\k";    // Non-compliant
   const char_t b[ 2 ] = "\b";    // Compliant
}