Skip to main content

IAR Embedded Workbench for RISC-V 3.40

RED-cond-const

In this section:
Synopsis

A constant value is used as the condition for a loop or if statement.

Enabled by default

No

Severity/Certainty

Low/High

lowhigh.png
Full description

A constant value is used as the condition for a loop or if statement. This might be an error. If the condition is part of a for or while loop, it will never terminate.

Coding standards
CWE 570

Expression is Always False

CWE 571

Expression is Always True

Code examples

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

void example(void) {
  int x = 0;
  while (10){
    ++x;
  }
}

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

void example(void) {
  int x = 0;
  while (x < 10){
    ++x;
  }
}