Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 8.10, I don't understand the Rationale
#5
Ok, from the wording of the rule - but not the rationale - that may be the undefined behaviour that rule 8.10 was intended to prevent.

The rationale appears to disagree, though. It describes behaviour which is equally undefined for inline functions of static, as well as external, linkage.

But this undefined behaviour is avoided by the normal (for inline functions) practice of defining the external function in the header file, and having the declaration in the single translation unit which is to contain the external instance of the function. This is suggested by the Note at the end of the rationale; it should have been in the text of the rule. From N1256 paragraph 6.7.4.3 and footnote 122 etc., it seems that coding guidelines concerned with code safety should also forbid static inline functions shared among several translation units, instead of allowing them and even promoting their use.

It would be nice if someone from Misra could explain why this rule, and in particular the definition of static inline functions in headers, is allowable in code that wants to ensure correct behaviour.
<t></t>


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)