主要内容

AUTOSAR C++14 Rule A21-8-1

Arguments to character-handling functions shall be representable as an unsigned char

描述

规则定义

Arguments to character-handling functions shall be representable as an unsigned char.

理由

您不能将普通 char 变量用作在 <cctype> 中声明的字符处理函数的参量,例如 isalpha()isdigit()。在某些平台上,普通 char 变量可能具有无法用 unsigned char 或 EOF 表示的负值,从而导致未定义行为。

Polyspace 实现

当您将具有负值的有符号或普通 char 变量用作字符处理函数的参量时,检查操作会标记违规。

故障排除

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

检查信息

组:字符串库
类别:必需、自动

版本历史记录

在 R2019a 中推出