AutosarC++18_03-A2.13.1¶
Only those escape sequences that are defined in ISO/IEC 14882:2014 shall be used
Required inputs: IR
| Level | required |
|---|---|
| Target | architecture / design / implementation |
| Enforcement | automated |
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>.
Note: Universal-character-names (\u hex-quad and \U hex-quad hex-quad) are also allowed in character and string literals (although they look similar to escape sequences, they are handled in a different way by the C++ language, see A2-13-6).
Example
//% $Id: A2-13-1.cpp 305629 2018-01-29 13:29:25Z piotr.serwa $
#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¶
This rule shares the following common options: confidence, exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
allow_delimited_escape_sequences¶
allow_delimited_escape_sequences : bool = False
allowed¶
allowed : str = ''"?\abfnrtv'