MISRA Advisory: Only ISO C escape sequences are allowedCXX-W3014
MISRA-C:2012 Advisory Rule 4.1 states that only ISO C escape sequences are allowed in character constants and string literals. Non-ISO C escape sequences can lead to undefined behavior in C++.
One example of a non-standard escape sequence is the vertical tab character, \v
, which is not part of the ISO C standard and is not supported by all compilers.
The use of non-standard escape sequences can cause readability and portability issues, and could prevent developers using other compilers from being able to compile your code.
Only use escape sequences which are supported as per the ISO C++ standard in your code.
Bad practice
char str[10] = "Hello\cWorld";
This code uses a non-ISO C escape sequence \c
. It can lead to undefined behavior.
Recommended
char str[10] = "Hello\\cWorld";
This code uses the ISO C escape sequence \\
to escape the backslash character.