Skip to main content

IAR Embedded Workbench for RL78 5.20

MISRAC2012-Rule-11.4

In this section:
Synopsis

(Advisory) A conversion should not be performed between a pointer to object and an integer type

Enabled by default

No

Severity/Certainty

Low/Medium

lowmedium.png
Full description

A cast between a pointer type and an integral type was found. This check is identical to MISRAC2004-11.3, MISRAC++2008-5-2-9, MISRAC++2023-8.2.7.

Coding standards
MISRA C:2004 11.3

(Advisory) A cast should not be performed between a pointer type and an integral type.

MISRA C++ 2008 5-2-9

(Advisory) A cast should not convert a pointer type to an integral type.

MISRA C++ 2023 8.2.7

(Advisory) A cast should not convert a pointer type to an integral type

Code examples

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

void example(void) {
  int *p;
  int x;
  x = (int)p;
}

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

void example(void) {
  int *p;
  int *x;
  x = p;
}