Article View: comp.std.c
Article #627Re: Declarations in switches, errors
From: Conor P. Cahill
Date: Fri, 29 Sep 1989 00:30
Date: Fri, 29 Sep 1989 00:30
34 lines
1805 bytes
1805 bytes
In article <11173@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn) writes:
> In article <1202@virtech.UUCP>, cpcahil@virtech.UUCP (Conor P. Cahill) writes:
> > If this is the standard, I think it is broken. If the compiler allows
> > a variable declaration, it should allow an initialization.
> If I recall correctly (my copy of the Standard is not at hand), you can
> specify the initializer but of course it won't be executed. Consider
> the following analogous case (which does NOT involve "switch") to see why:
>
> goto label;
> {
> int i = 4;
> foo();
> label: bar();
> baz();
> }
I still don't agree with this. One does not "conceptualize" the initialization
as an execution. Since the code used to allocate the automatic variable on
the stack is executed, the code used to initialize the variable should be
executed.
In addition the behavior is different if the declaration is "static int...".
In that case the initialization does take place. What it the justification
for the different behavior?
--
+-----------------------------------------------------------------------+
| Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 !
| Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 |
+-----------------------------------------------------------------------+
Technical Details
Message-ID:
<1211@virtech.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!ginosko!uunet!virtech!cpcahilReferences:
<561@crdos1.crd.ge.COM> <10041@xanth.cs.odu.edu> <1202@virtech.UUCP> <11173@smoke.BRL.MIL>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!ginosko!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.std.c Subject: Re: Declarations in switches, errors Message-ID: <1211@virtech.UUCP> Date: 29 Sep 89 00:30:59 GMT References: <561@crdos1.crd.ge.COM> <10041@xanth.cs.odu.edu> <1202@virtech.UUCP> <11173@smoke.BRL.MIL> Organization: Virtual Technologies Inc Lines: 34