MISRAC2012-Rule-11.2
In this section:
Synopsis
(Required) Conversions shall not be performed between a pointer to an incomplete type and any other types.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
A conversion from or to an incomplete type pointer was found. This check is identical to CERT-EXP39-C_c.
Coding standards
- CERT EXP39-C
Do not access a variable through a pointer of an incompatible type
- MISRA C:2012 Rule-11.2
(Required) Conversions shall not be performed between a pointer to an incomplete type and any other type
Code examples
The following code example fails the check and will give a warning:
struct a;
struct b;
void example(void) {
struct a * p1;
struct b * p2;
unsigned int x;
p1 = (struct a *) 0x12345678;
x = (unsigned int) p2;
p1 = (struct a *) p2;
}
The following code example passes the check and will not give a warning about this issue:
#include <stdlib.h>
struct a;
extern struct a *f (void);
void example(void) {
struct a * p;
unsigned int x;
/* exception 1: NULL -> incomplete type ptr */
p = (struct a *) NULL;
/* exception 2: incomplete type ptr -> void */
(void) f();
}