Xref: news2.mv.net comp.os.msdos.djgpp:738 From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: v2 vs v1 C++ interpretation Date: Fri, 02 Feb 1996 12:42:37 -0800 Organization: &tSftDotIotE Lines: 31 Message-ID: <3112773D.26886015@alcyone.com> References: <4eads7$4e6 AT trog DOT dra DOT hmg DOT gb> NNTP-Posting-Host: newton.alcyone.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp itmiller AT taz DOT dra DOT hmg DOT gb wrote: > I am confident that it is valid code as it is just a cut down version > of one of the functions in the desk calculator in Bjarne Stroustrup's > "The C++ Programming Language", second edition. The problem is that the default case label is jumping past the initialization of a local variable. In _The Annotated C++ Reference Manual_, Ellis & Stroustrup, p. 86: Declarations may appear in the _statement_ of a switch-statement. It is illegal, however, to jump past a declaration with an explicit or implicit initializer unless the declaration is in an inner block that is not entered (that is, completely bypassed by the transfer of control . . .). This is exactly what you're trying to do here. (In this case the jump is irrelevant since your default switch section does not reference d, but it is still illegal.) Your choices are either to declare the variable outside of the switch statement, in its surrounding block, or to make a subblock inside the switch statement which contains the declaration of the variable. -- Erik Max Francis, &tSftDotIotE. && max AT alcyone DOT darkside DOT com || max AT alcyone DOT com San Jose, California, U.S.A. && 37 20 07 N 121 53 38 W && the 4th R is respect H.3`S,3,P,3$S,#$Q,C`Q,3,P,3$S,#$Q,3`Q,3,P,C$Q,#(Q.#`-"C`- && 1love && folasade Omnia quia sunt, lumina sunt. && GIGO Omega Psi && http://www.alcyone.com/max/ "Out from his breast/his soul went to seek/the doom of the just." -- _Beowulf_