AutosarC++17_03-A2.14.1

Only those escape sequences that are defined in ISO/IEC 14882:2014 shall be used

Required inputs: IR

Rationale

The use of an undefined escape sequence leads to undefined behavior. The defined escape sequences (ISO/IEC 14882:2014) are: \’, \", \?, \\, \a, \b, \f, \n, \r, \t, \v, \<Octal Number>, \x<Hexadecimal Number>, \U<Unicode Character Name>

Example
//% $Id: A2-14-1.cpp 266557 2017-02-07 13:08:19Z piotr.tanski $
#include <string>
void f() {
const std::string a = "\k";         // Non-compliant
const std::string b = "\n";         // Compliant
const std::string c = "\U0001f34c"; // Compliant
}
See Also
  • MISRA C++ 2008 [6]: required 2-13-1 Only those escape sequences that are defined in ISO/IEC14882:2003 shall be used.

Possible Messages

Key

Text

Severity

Disabled

nonstandard_escape_sequence

Use of non-standard escape sequence.

None

False

Options

allow_delimited_escape_sequences

allow_delimited_escape_sequences : bool = False

Whether to allow C++23 escape sequences that are delimited by curly braces. This includes the delimited escape sequences `\u{}`, `\x{}`, and `\o{}` as well as named universal character escapes of the form `\N{}`.
 

allowed

allowed : str = ''"?\abfnrtv'

List of allowed characters after backslash.