[previous] 0371 [next] [L] Nesting levels of blocks exceeds 127 - program does not conform strictly to ISO:C99.
ISO C99 Conformance limits REFERENCE - ISO:C99-5.2.4.1 Translation Limits

The translation limits specified in the ISO:C Standard define a minimum set of conditions which a compiler must support in order to be described as conforming. In practice, compilers will often tolerate code which exceeds these minimal requirements. However, in order to ensure portability, it is advisable to avoid writing code which assumes a level of compiler capability which may not always be supported.

Message 0371 identifies situations where the level of statement nesting exceeds the minimum requirement of the ISO:C99 Standard. Message 0715 identifies code which breaches the corresponding ISO:C90 limit; however it should be noted that the definitions of nesting differ in the 2 standards.

The ISO:C99 specification for statement nesting requires a compiler to support 127 levels of "blocks" where blocks are defined as follows: Consider the following code example:

if ( x > 0)
{
   ...
}

This will correspond to a nesting level of 3 (2 levels for the if statement and 1 level for the compound statement within it).

By comparison, ISO:C90 specifies a limit of only 15 "nesting levels of blocks", but, as noted above, the definition of nesting is rather different.

Note also that the algorithm used to calculate the STMIF metric ("Maximum nesting of control structures") is different yet again. The STMIF metric is incremented in iteration and selection control statements but not in compound statements. This algorithm corresponds more directly with the nesting levels conventionally represented visually by code indentation.


MISRA C:2012 Rules applicable to message 0371:

Dir-1.1  (Required) Any implementation-defined behaviour on which the output of the program depends shall be documented and understood


See also:

QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents