Skip to main content

IAR Embedded Workbench for RL78 5.20

CERT-MSC38-C

In this section:
Synopsis

Do not treat a predefined identifier as an object if it might only be implemented as a macro

Enabled by default

Yes

Severity/Certainty

Low/Low

lowlow.png
Full description

Do not suppress standard library macros that yields undefined behavior by accessing the underlying function

Coding standards
CERT MSC38-C

Do not treat as an object any predefined identifier that might be implemented as a macro

Code examples

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

#include <assert.h>

typedef void (*handler_type)(int);

void execute_handler(handler_type handler, int value) {
  handler(value);
}

void func(int e) {
  execute_handler(&(assert), e < 0);
}

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

#include <assert.h>

typedef void (*handler_type)(int);

void execute_handler(handler_type handler, int value) {
  handler(value);
}

static void assert_handler(int value) {
  assert(value);
}

void func(int e) {
  execute_handler(&assert_handler, e < 0);
}