主要内容

MISRA C++:2023 Rule 5.0.1

Trigraph-like sequences should not be used

自 R2024b 起

描述

规则定义

Trigraph-like sequences should not be used. 1

理由

可以用两个问号后跟一个特定的第三个字符来表示三字符序列(例如,'??-' 表示一个 '~'(波浪号)字符,'??)' 表示一个 ']' 字符)。这些三字符序列可能会与两个问号的其他用法意外混淆。

例如,字符串

"(Date should be in the form ??-??-??)"
被转换为
"(Date should be in the form ~~]"
但此转换可能不是有意为之。

Polyspace 实现

规则检查项会对三字符序列的使用报告违规,无论三字符序列是用在字符串中还是用在其他地方。

故障排除

如果您预期会出现违规,而 Polyspace® 未报告该违规,请参阅诊断为何编码规范违规未按预期显示

检查信息

组:词法规范
类别:建议

版本历史记录

在 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.