11-05-2015, 07:51 AM
To aid other readers of this question we will start by recapping the C99 descriptions of tentative definitions.
Your example is similar to the example "i4" in Example of section 6.9.2 of the C99 standard. This shows that the:Paragraph 2 of section 6.9.2 states
Your example is similar to the example "i4" in Example of section 6.9.2 of the C99 standard. This shows that the:
Code:
first "int i" is a tentative definition with external linkage
second "int i" is also a valid tentative definition which refers to the previous definition.
Quote:If a translation unit contains one or more tentative definitions for an identifier, and the translation unit contains no external definition for that identifier, then the behaviour is exactly as if the translation unit contains a file scope declaration of that identifier, with an initialiser equal to 0.Your example does not violate rule 8.4, but will violate rule 8.6 or 8.7 depending on the rest of the code.
Posted by and on behalf of the MISRA C Working Group