According to the C Standard, 7.4.1 paragraph 1 [ISO/IEC 9899:20112024],
The header
<ctype.h>
declares several functions useful for classifying and mapping characters. In all cases the argument is anint
, the value of which shall be representable as anunsigned char
or shall equal the value of the macroEOF
. If the argument has any other value, the behavior is undefined.
See also undefined behavior 113112.
This rule is applicable only to code that runs on platforms where the char
data type is defined to have the same range, representation, and behavior as signed char
.
...
Tool | Version | Checker | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Astrée |
| ctype-limits | Partially checked | ||||||||||||||||||
Axivion Bauhaus Suite |
| CertC-STR37 | Fully implemented | ||||||||||||||||||
CodeSonar |
| MISC.NEGCHAR | Negative character value | ||||||||||||||||||
Compass/ROSE | Could detect violations of this rule by seeing if the argument to a character handling function (listed above) is not an | ||||||||||||||||||||
| CC2.STR37 | Fully implemented | |||||||||||||||||||
Helix QAC |
| C4413, C4414 C++3051 | |||||||||||||||||||
Klocwork |
| AUTOSAR.STDLIB.CCTYPE.UCHAR MISRA.ETYPE.ASSIGN.2012 | |||||||||||||||||||
LDRA tool suite |
| 663 S | Fully implemented | ||||||||||||||||||
Parasoft C/C++test |
| CERT_C-STR37-a | Do not pass incorrect values to ctype.h library functions | ||||||||||||||||||
Polyspace Bug Finder |
| Checks for invalid Invalid use of standard library integer routine | Wrong arguments to standard library function Data type conversion with sign extension causes unexpected behavior | PRQA QA-C | |||||||||||||||||
Include Page | PRQA QA-C_v | PRQA QA-C_v | 4413, 4414 | Fully implemented | PRQA QA-C++ | ||||||||||||||||
Include Page | cplusplus:PRQA QA-C++_V | cplusplus:PRQA QA-C++_V | (rule fully covered) | ||||||||||||||||||
3051 | RuleChecker |
| ctype-limits | Partially checked | |||||||||||||||||
TrustInSoft Analyzer |
| valid_char | Partially verified. |
...
Bibliography
[ISO/IEC 9899:20112024] | 7.4.1, "Character Handling <ctype.h >" |
[Kettlewell 2002] | Section 1.1, "<ctype.h > and Characters Types" |
...