Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC2012-Rule-11.1

In this section:
Synopsis

(Required) Conversions shall not be performed between a pointer to a function and any other type

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Conversion between a pointer to a function and another type were found. This check is identical to CERT-EXP39-C_b.

Coding standards
CERT EXP39-C

Do not access a variable through a pointer of an incompatible type

MISRA C:2012 Rule-11.1

(Required) Conversions shall not be performed between a pointer to a function and any other type

Code examples

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

#include <stdlib.h>

void example(void) {
  int (*fptr)(int,int);
  (int*)fptr;
}

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

typedef void ( *fp16 ) ( int n );
typedef fp16 ( *pfp16 ) ( void );

void example(void) {
    pfp16 pfp1;
    ( void ) ( *pfp1 ( ) );   /* Compliant - exception 2 - cast function
                               * pointer into void */
}