MISRA C++:2023 Rule 5.13.2
Octal escape sequences, hexadecimal escape sequences and universal character names shall be terminated
自 R2024b 起
描述
Octal escape sequences, hexadecimal escape sequences and universal character names shall be terminated. 1
理由
如果一个八进制/十六进制转义序列或通用字符名称后面紧跟着其他字符,可能会导致混淆。例如,字符常量 '\x1f' 由单个字符组成,而字符常量 '\x1g' 则由两个字符 '\x1' 和 'g' 组成。多字符常量表示为整数的方式由实现定义。
如果字符常量或字符串字面值中的每个八进制和十六进制转义序列以及通用字符名称都明确终止,则可以减少潜在的混淆。
Polyspace 实现
如果转义序列或通用字符名称没有以字符串结束字面值或另一个转义序列来终止,规则检查项会报告违规。
故障排除
如果您预期会出现违规,而 Polyspace® 未报告该违规,请参阅诊断为何编码规范违规未按预期显示。
示例
检查信息
| 组:词法规范 |
| 类别:必需 |
PQL 名称:std.misra_cpp_2023.R5_13_2 |
版本历史记录
在 R2024b 中推出
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
MISRA C:2004
MISRA C:2012
MISRA C:2023
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.