MISRA C++:2023 Rule 24.5.1
The character handling functions from <cctype>
and
<cwctype>
shall not be used
Since R2024b
Description
Rule Definition
The character handling functions from <cctype>
and
<cwctype>
shall not be used.
Rationale
The functions from <cctype>
and
<cwctype>
are locale-dependent. Therefore, in some locales, these
character handling functions do not handle extended character sets or unicode characters
properly, or they can have inconsistent behavior in programs intended to run in multiple
locales. These functions can also produce undefined behavior if the input character is not
representable as unsigned char
or is not equal to the value of the macro
EOF
.
Functions from the standard template library <locale>
are safer to
use because they correctly handle character classification and case conversion based on the
locale you specify.
Polyspace Implementation
The rule checker reports a violation whenever the code uses functions from
<cctype>
or <cwctype>
, such as
islower()
or iswdigit()
.
Troubleshooting
If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Strings Library |
Category: Required |
Version History
Introduced in R2024b