Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC2004-20.10

In this section:
Synopsis

(Required) The functions atof, atoi, and atol from the library stdlib.h shall not be used.

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

Use of the functions atof, atoi, atol, or atoll was detected. This check is identical to MISRAC++2008-18-0-2, MISRAC2012-Rule-21.7, MISRAC++2023-21.2.1.

Coding standards
CERT INT06-C

Use strtol() or a related function to convert a string token to an integer

MISRA C:2012 Rule-21.7

(Required) The atof, atoi, atol and atoll functions of <stdlib.h> shall not be used

MISRA C++ 2008 18-0-2

(Required) The library functions atof, atoi and atol from library <cstdlib> shall not be used.

MISRA C++ 2023 21.2.1

(Required) The library functions atof, atoi, atol and atoll from <cstdlib> shall not be used

Code examples

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

#include <stdlib.h>

int example(char buf[]) {
  return atoi(buf);
}

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

void example(void) {
}