Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC++2023-7.0.2 (C++ only)

In this section:
Synopsis

(Required) There shall be no conversion to type bool

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Conversion to bool shall not be used

Coding standards

This check does not correspond to any coding standard rules.

Code examples

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

int example(int x) {
  if (x) return 0;
  return 1;
}

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

int example(int x) {
  if (x != 0) return 0;
  return 1;
}