Article View: comp.std.c
Article #2367Re: Initialization of automatics within loops
From: Bruce Blodgett
Date: Wed, 06 Feb 1991 15:57
Date: Wed, 06 Feb 1991 15:57
35 lines
1723 bytes
1723 bytes
In article <2293@inews.intel.com> bhoughto@hopi.intel.com (Blair P. Houghton) writes:
> Note that in:
>
> /* just a block to scope-limit foo and bar */
> {
> int foo = 3;
> mickle:
> int bar = 0111;
>
> foo *= bar;
> }
>
> `mickle:' labels `foo *= bar;', which is a statement,
> rather than `int bar = 0111;', which is a declaration, not
> a statement. So, despite the fact that `int bar = 0111;'
> appears after `mickle:', it is guaranteed that neither
> initialization is performed.
Section 3.6.1 (Labeled Statements) provides relevant syntax:
labeled-statement:
identifier : statement
As does Section 3.6.2 (Compound Statement, or Block):
compound-statement:
{ opt-declaration-list opt-statement-list }
Your declarations of foo and bar make up the optional
declaration-list. foo *= bar; makes up the optional statement-list.
The label mickle: precedes a declaration, not a statement. This is
not syntactically legal. There is not a question of whether to assign
0111 to bar "if the block is entered by a jump to a labeled
statement", because you have not provided a legal code fragment.
Bruce Blodgett
blodgett@apollo.hp.com
(508) 256-0176 x4037
Technical Details
Message-ID:
<4fa77adf.20b6d@apollo.HP.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!samsung!sdd.hp.com!apollo!blodgettReferences:
<1991Feb5.023809.389086@locus.com> <2293@inews.intel.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!samsung!sdd.hp.com!apollo!blodgett From: blodgett@apollo.HP.COM (Bruce Blodgett) Newsgroups: comp.std.c Subject: Re: Initialization of automatics within loops Message-ID: <4fa77adf.20b6d@apollo.HP.COM> Date: 6 Feb 91 15:57:00 GMT References: <1991Feb5.023809.389086@locus.com> <2293@inews.intel.com> Sender: root@apollo.HP.COM Lines: 35 In-reply-to: bhoughto@hopi.intel.com's message of 5 Feb 91 17:03 GMT