MISRA C:2023 Rule 11.8
A conversion shall not remove any const
,
volatile
, or _Atomic
qualification from the type
pointed to by a pointer
Since R2024a
Description
Rule Definition
A conversion shall not remove any const
,
volatile
, or _Atomic
qualification from the type
pointed to by a pointer.
Rationale
This rule forbids conversions that violate type qualification:
Casts from a pointer to a
const
object to a pointer that does not point to aconst
object. Removing theconst
qualifier allows the program to modify objects that are intended to be read-only. Attempting to access such a converted object can result in an exception.Casts from a pointer to a
volatile
object to a pointer that does not point to avolatile
object. Removing thevolatile
qualifier can allow the compiler to remove accesses to this object during optimization.Casts from a pointer to an
_Atomic
object to a pointer that does not point to a_Atomic
object. Removing the_Atomic
qualifier allows the program to circumvent the lock status of an object, resulting in memory corruption.
Polyspace Implementation
Polyspace® flags both implicit and explicit conversions that violate this rule.
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Pointer Type Conversions |
Category: Required |
AGC Category: Required |
Version History
Introduced in R2024a