...
Accessing an object by means of any other lvalue expression (other than unsigned char) is undefined behavior 3736.
Noncompliant Code Example
...
According to the C Standard, 6.7.7.3 [ISO/IEC 9899:2024], using two or more incompatible arrays in an expression is undefined behavior. (See also undefined behavior 7673.)
For two array types to be compatible, both should have compatible underlying element types, and both size specifiers should have the same constant value. If either of these properties is violated, the resulting behavior is undefined.
...
Recommendation | Severity | Likelihood | Detectable | Remediation CostRepairable | Priority | Level |
|---|---|---|---|---|---|---|
EXP39-C | Medium | Unlikely | No | HighNo | P2 | L3 |
Automated Detection
Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Cppcheck Premium |
| premium-cert-exp39-cPartially implemented | |||||||
| Helix QAC |
| C0310, C0751, C3305 C++3017, C++3030, C++3033 | |||||||
| Klocwork |
| MISRA.CAST.FUNC_PTR.2012 | |||||||
| LDRA tool suite |
| 94 S, 554 S | Partially implemented | ||||||
| Parasoft C/C++test |
| CERT_C-EXP39-a | There shall be no implicit conversions from integral to floating type | ||||||
| Polyspace Bug Finder |
| Checks for cast to pointer pointing to object of different type (rule partially covered) | |||||||
| PVS-Studio |
| V580 |
...