Skip to main content

IAR Embedded Workbench for RX 5.20

MISRAC++2008-7-5-4_b

In this section:
Synopsis

(Advisory) Functions should not call themselves, either directly or indirectly.

Enabled by default

No

Severity/Certainty

Low/Medium

lowmedium.png
Full description

There are functions that call themselves indirectly. This check is identical to MISRAC2004-16.2_b, MISRAC2012-Rule-17.2_b, MISRAC++2023-8.2.10_b.

This is a link analysis check.

Coding standards
MISRA C:2004 16.2

(Required) Functions shall not call themselves, either directly or indirectly.

MISRA C:2012 Rule-17.2

(Required) Functions shall not call themselves, either directly or indirectly

MISRA C++ 2023 8.2.10

(Required) Functions shall not call themselves, either directly or indirectly

Code examples

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

void example1(void);
void callee1(void) {
    example1();
}
void example1(void) {
    callee1();
}

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

void callee2(void) {
    ;
}
void example2(void) {
    callee2();
}