Why is this an issue?
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
Resources
- 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.