C99 The C standard defines octal constants as a 0 followed by octal digits (0 1 2 3 4 5 6 7).
...
Code Block | ||||
---|---|---|---|---|
| ||||
i_array[0] = 2719;
i_array[1] = 4435;
i_array[2] = 0042;
|
Although it may appear that that i_array[2]
is assigned the decimal value 42, it is actually assigned the decimal value 34.
...
To avoid using wrong values and make the code more readable, don't do not preface constants with zeroes if the value is meant to be decimal.
Code Block | ||||
---|---|---|---|---|
| ||||
i_array[0] = 2719;
i_array[1] = 4435;
i_array[2] = 42;
|
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
DCL18-C | low | unlikely | low | P3 | L3 |
Related Guidelines
ISO/IEC 9899:19992011 Section 6.4.4.1 "Integer constants"
MISRA Section 6.7, Rule 7.1
Bibliography
...