Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 9.2 in TC1
#2
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.
Posted by and on behalf of the MISRA C Working Group


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)