Declarations in switches, errors

Henry Spencer henry at utzoo.uucp
Sat Sep 30 03:05:39 AEST 1989


In article <561 at crdos1.crd.ge.COM> davidsen at crdos1.UUCP (bill davidsen) writes:
> switch (i) {
>  int j = 4;
> case 1: /* ... */
>
>Note the initialization in the 4th statement. I was unable to find any
>compiler which generated working code for this initialization...
>(3.1.2.4) says "If an initialization is specified for the value stored
>in the object, it is performed on each normal entry, but not if the
>block is entered by a jump to a label."
>I submit that executing a switch statement constitutes "normal entry"...

Sorry, wrong.  3.6.4.2:  "...control jumps to the statement following
the matched case label..."  Also note the example in 3.6.4.2, which
explicitly makes the point that initializers in such a context are
not executed.
-- 
"Where is D.D. Harriman now,   |     Henry Spencer at U of Toronto Zoology
when we really *need* him?"    | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.std.c mailing list