Rule 11.8: non-compatible pointees - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21) +---- Forum: 8.11 Pointer type conversions (https://forum.misra.org.uk/forumdisplay.php?fid=166) +---- Thread: Rule 11.8: non-compatible pointees (/showthread.php?tid=1304) |
Rule 11.8: non-compatible pointees - pmhill - 05-01-2017 In the following code I would like to know which of the casts are compliant for rule 11.8? [code] const int a[10]; int *pi; int **ppi; const int **cppi; const float **cppf; void f() { pi = (int*) &a; /* int * Re: Rule 11.8: non-compatible pointees - misra-c - 30-03-2017 This rule only applies to the type qualifiers of the type pointed to by the top-level pointer. For example: It is a violation of this rule to cast an object of type "X const *" to "Y *". The presence/absence of type qualifiers within X or Y are covered by rule 11.3 and not by this rule. For example: Code: "const int **ppci" is a "pointer to pointer to const int". Looking at the specific examples Code: pi = (int*) &a; |