...
Converting from pointer to integer or vice versa results in code that is not portable and may create unexpected pointers to invalid memory locations.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
INT36-C | Low | Probable | High | P2 | L3 |
Automated Detection
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
Astrée |
| pointer-integral-cast pointer-integral-cast-implicit function-pointer-integer-cast function-pointer-integer-cast-implicit | Fully checked | ||||||
Clang |
| -Wint-to-pointer-cast , -Wint-conversion | Can detect some instances of this rule, but does not detect all | ||||||
CodeSonar |
| LANG.CAST.PC.CONST2PTR LANG.CAST.PC.INT | Conversion: integer constant to pointer Conversion: pointer/integer | ||||||
Compass/ROSE |
Coverity |
| PW.POINTER_CONVERSION_LOSES_BITS | Fully implemented | ||||||
Klocwork |
| MISRA.CAST.OBJ_PTR_TO_INT.2012 |
LDRA tool suite |
| 439 S, 440 S | Fully implemented | ||||||
Parasoft C/C++test |
|
|
| MISRA2008-5_2_8, CODSTA-127_b | Fully implemented | |||||||
PRQA QA-C |
| 305, 306, 309, 429, 432, 557, 563, 671, 674 | Partially implemented | ||||||
RuleChecker |
| pointer-integral-cast pointer-integral-cast-implicit function-pointer-integer-cast function-pointer-integer-cast-implicit | Fully checked | ||||||
SonarQube C/C++ Plugin |
| S1767 | Partially implemented |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...
Key here (explains table format and definitions)
Taxonomy | Taxonomy item | Relationship |
---|---|---|
CERT C | INT11-CPP. Take care when converting from pointer to integer or integer to pointer | Prior to 2018-01-12: CERT: Unspecified Relationship |
ISO/IEC TR 24772:2013 | Pointer Casting and Pointer Type Changes [HFC] | Prior to 2018-01-12: CERT: Unspecified Relationship |
ISO/IEC TS 17961:2013 | Converting a pointer to integer or integer to pointer [intptrconv] | Prior to 2018-01-12: CERT: Unspecified Relationship |
CWE 2.11 | CWE-587, Assignment of a Fixed Address to a Pointer | 2017-07-07: CERT: Partial overlap |
CWE 2.11 | CWE-704 | 2017-06-14: CERT: Rule subset of CWE |
CWE 2.11 | CWE-758 | 2017-07-07: CERT: Rule subset of CWE |
CERT-CWE Mapping Notes
Key here for mapping notes
...
- Illegal pointer-to-integer conversion
Bibliography
[ISO/IEC 9899:2011] | 6.3.2.3, "Pointers" |
...
...