Declarations in switches, errors

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Oct 1 10:25:47 AEST 1989


In article <30540 at news.Think.COM> barmar at kulla (Barry Margolin) writes:
>Well, since the initial value of automatic variables is undefined, a
>conforming implementation COULD execute them.

NO, not in general.  (The only time it could occur is if it would
have no observable effect!  What would be the point of that?)

>why does the standard permit initializers in declarations at the head
>of a switch body, if they are required to be ignored?

Because it's attempting to standardize C, not some vaguely similar
language.

The initializer IS NOT REQUIRED TO BE IGNORED.  It is treated
EXACTLY like any other auto initializer.  Static initializers
in a switch body are also treated like any other static initializers.

You guys have the wrong mental model of C initialization!



More information about the Comp.std.c mailing list