Initialization of automatics within loops

Rick Schubert rns at tortuga.SanDiego.NCR.COM
Thu Feb 7 12:27:02 AEST 1991


In article <2293 at inews.intel.com> bhoughto at hopi.intel.com (Blair P. Houghton) writes:
>In article <1991Feb5.023809.389086 at locus.com> geoff at locus.com (Geoff Kuenning) writes:
>>(BTW, the
>>spec explicitly says that implementations get to decide whether automatics
>>are initialized upon jumps into a compound statement,

>No it doesn't.

>Ergo, jump to a labeled statement, and the initialization is skipped.

>Note that in:

>	/* just a block to scope-limit foo and bar */
>	{
>	    int foo = 3;
>mickle:
>	    int bar = 0111;
>
>	    foo *= bar;
>	}

>                         it is guaranteed that neither
>initialization is performed.

Someone else answered that the label is invalid here, so I'll proceed as
if the label were after the declarations.  In this case it CANNOT be
guaranteed that the initialization is NOT performed since there is no way
to tell (in a Standard Conforming program) that the initialization was or
was not done.  There is no way to test for an uninitialized value.  The only
thing that would be invalid for the implementation (compiler) to do would
be to evaluate an initialization expression that had side-effects that could
be tested for.

-- Rick Schubert (rns at tortuga.SanDiego.NCR.COM)



More information about the Comp.std.c mailing list