3.7 constraints and 3.7.2 semantics

Blair P. Houghton bhoughto at hopi.intel.com
Tue Mar 19 14:49:38 AEST 1991


Didn't this just go around? Or is this the "Now let me
get this straight" version of the question?

In article <5450 at mcrware.UUCP> jejones at mcrware.UUCP (James Jones) writes:
>Does p.82, lines 13-15, imply that the following is not standard conforming,
>or does p.84, lines 31-34, provide an escape hatch?

"No" to the first; and, "it works but it's not escaping from
anything" to the second.

When the citation on p. 84 says "the behavior is exactly as
if the translation unit contains a file scope
declaration...with an initializer equal to 0", the
imaginary declaration-with-initializer satisfies the
requirement from the citation on p. 82, for there to be
"exactly one" external definition.

I.e., though the explicit external definition is absent, it
still properly reserves and initializes storage, which
appears to be the intent (the rationale is mute on this).

It gets away with this by hiding any definitions for `i'
with external linkage from other translation units.

I think the sentence on p. 84 could've done with a footnote.

                           vvvvvvvvvvvvv---could be "translation unit"
>--------------------begin code fragment
>static int	i;	/* tentative definition, internal linkage */
>
>int
>woof(void)
>{
>	return ++i;	/* usage other than in sizeof() */
>}
>--------------------end code fragment

Due to the implicit initial zero, woof() should return 1
the first time it's called, 2 the second, 3 the third, and
so on, when compiled by a conforming implementation.

				--Blair
				  "At least, that's how I read
				   it.  Your parsimony may vary."



More information about the Comp.std.c mailing list