MISRAC++2023-5.13.1
In this section:
Synopsis
(Required) Within character literals and non raw-string literals, \ shall only be used to form a defined escape sequence or universal character name
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
Bad escape sequence This check is identical to MISRAC++2008-2-13-1, MISRAC2004-4.1.
Coding standards
- MISRA C:2004 4.1
(Required) Only those escape sequences that are defined in the ISO C standard shall be used.
- MISRA C++ 2008 2-13-1
(Required) Only those escape sequences that are defined in ISO/IEC 14882:2003 shall be used.
Code examples
The following code example fails the check and will give a warning:
void example() {
const char * row = "Price:\T %d"; // Non-compliant
}
The following code example passes the check and will not give a warning about this issue:
void example() {
const char * row = "Price:\t %d"; // Compliant
}