# V2501. MISRA. Octal constants should not be used.

This diagnostic rule is based on the software development guidelines developed by MISRA (Motor Industry Software Reliability Association).

This diagnostic rule varies for C and C++. In the C language, octal numeric literals should not be used. In the C++ language, octal numeric literals and escape sequences should not be used.

The use of octal literals could hinder code readability, especially when skimming through it. Misinterpreting numeric values may result in various mistakes.

Here is an example of code triggering this warning:

    if (val < 010)
    {
      ....
    }

When skimming through the code, you may overlook the actual value of the numeric literal, which is 8, not 10. To eliminate this warning, rewrite the literal in decimal or hexadecimal form:

    if (val < 8)
    {
      ....
    }

This diagnostic is classified as:

MISRA-C-2012-7.1 MISRA-C-2023-7.1 MISRA-CPP-2008-2.13.2