Skip to main content

IAR Embedded Workbench for RX 5.20

CERT-MSC40-C_a

In this section:
Synopsis

Do not violate constraints.

Enabled by default

Yes

Severity/Certainty

Low/Low

lowlow.png
Full description

The C Standard, 6.7.4, paragraph 3 outlines the following constraint: An inline definition of a function with external linkage shall not contain a definition of a modifiable object with static or thread storage duration, and shall not contain a reference to an identifier with internal linkage. This check finds cases where a static object is referenced in an inline function.

Coding standards
CERT MSC40-C

Do not violate constraints

Code examples

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

static int I = 12;
extern inline void func(int a) {
    int b = a * I;
    /* ... */
}

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

int I = 12;
extern inline void func(int a) {
    int b = a * I;
    /* ... */
}