26-02-2008, 04:17 PM
The purpose of Rule 9.2 is to ensure that initialiser for an object with aggregate type reflects the structure of that type in its brace nesting.
As originally stated, the rule recognised that all elements of an object with aggregate type could be initialised to 0 by explicitly initialising the first element only. The change introduced in TC1 restricted this type of initialisation to top-level aggregates only.
In retrospect the TC1 restriction is not helpful. As you have pointed out, it requires explicit entry of a sub-aggregate initialiser and this could be impractical if there is a large number of elements. Also, from a maintenance point of view, it can be easier not to have to write the initialiser explicitly.
This matter will be taken into consideration for future developments of MISRA C. In the meantime you could choose to deviate Rule 9.2 in the circumstances you have described.
As originally stated, the rule recognised that all elements of an object with aggregate type could be initialised to 0 by explicitly initialising the first element only. The change introduced in TC1 restricted this type of initialisation to top-level aggregates only.
In retrospect the TC1 restriction is not helpful. As you have pointed out, it requires explicit entry of a sub-aggregate initialiser and this could be impractical if there is a large number of elements. Also, from a maintenance point of view, it can be easier not to have to write the initialiser explicitly.
This matter will be taken into consideration for future developments of MISRA C. In the meantime you could choose to deviate Rule 9.2 in the circumstances you have described.
Posted by and on behalf of the MISRA C Working Group