MISRA C++:2023 Rule 8.2.6
An object with integral, enumerated, or pointer to void type shall not be cast to a pointer type
Since R2024b
Description
Rule Definition
An object with integral, enumerated, or pointer to void type shall not be cast to a pointer type. 1
Rationale
Casting void* pointer, integral types, or enumerated types to an
object with pointer type results in unspecified behavior.
Polyspace Implementation
The checker allows an exception on zero constants, such as 0x0,
0, or 0U.
Polyspace® does not report a violation if a void* pointer is converted
to a pointer to function.
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: Expressions |
| Category: Required |
Version History
Introduced in R2024b
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
MISRA C:2004
MISRA C:2012
MISRA C:2023
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.