Skip to main content

IAR Embedded Workbench for Arm 9.70.x

MISRAC2012-Rule-23.3

In this section:
Synopsis

(Advisory) A generic selection should contain at least one non-default association.

Enabled by default

No

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Found generic selection without non default association.

Coding standards
MISRA C:2012 Rule-23.3

(Advisory) A generic selection should contain at least one non-default association.

Code examples

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


#define no_op(X) _Generic( (X), default: X )

void example(void)
{
  int b = no_op(7);
}

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

/* Compliant - has a non-default and a default association */
#define no_opP(X) ( _Generic( (X) \
  , int:     (X) \
  , default: (X) ))

void example(void)
{
  int b = no_opP(7);
}