MISRA C++:2023 Rule 21.2.1
The library functions atof, atoi,
        atol and atoll from <cstdlib>
      shall not be used
Since R2024b
Description
Rule Definition
The library functions atof, atoi,
            atol and atoll from
            <cstdlib> shall not be used. 1
      
Rationale
Converting strings to a numeric value can result in error conditions, for instance, when the input string:
- Does not contain a number 
- Contains a number, but is out of range 
- Contains additional data after a number 
If you use C standard library functions such as atoi(),
        the preceding input errors might result in undefined behavior. Avoid using string-to-number
        functions such as atof(), atoi(),
          atoll(), and atoll() from the header
          <cstdlib>. Use C++ standard library functions, such as
          std::stoi(), std::stof(), and
          std::stol() instead.
Polyspace Implementation
Polyspace® flags the use of C standard library string-to-number functions of
          atoi(), atol(), atoll(), and
          atof(). 
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
| Group: Language support library | 
| Category: Required | 
Version History
Introduced in R2024b
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
- MISRA C:2004 
- MISRA C:2012 
- MISRA C:2023 
- MISRA C++:2008 
- MISRA C++:2023 
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.