Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC++2008-5-2-7

In this section:
Synopsis

(Required) An object with pointer type shall not be converted to an unrelated pointer type, either directly or indirectly.

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

A pointer to object type is cast to a pointer to a different object type. This check is identical to MISRAC2004-11.4.

Coding standards
MISRA C:2004 11.4

(Advisory) A cast should not be performed between a pointer to object type and a different pointer to object type.

Code examples

The following code example fails the check and will give a warning:

typedef unsigned int uint32_t;
typedef unsigned char uint8_t;

void example(void) {
	uint8_t * p1;
	uint32_t * p2;
	p2 = (uint32_t *)p1;
}

The following code example passes the check and will not give a warning about this issue:

typedef unsigned int uint32_t;
typedef unsigned char uint8_t;

void example(void) {
	uint8_t * p1;
	uint8_t * p2;
	p2 = (uint8_t *)p1;
}