Newsgroups: comp.std.c
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: Declarations in switches, errors
Message-ID: <1989Sep29.170539.29474@utzoo.uucp>
Organization: U of Toronto Zoology
References: <561@crdos1.crd.ge.COM>
Date: Fri, 29 Sep 89 17:05:39 GMT

In article <561@crdos1.crd.ge.COM> davidsen@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@zoo.toronto.edu