Xref: news2.mv.net comp.os.msdos.djgpp:719 From: "Gordon L. Scott" Newsgroups: comp.os.msdos.djgpp Subject: Re: v2 vs v1 C++ interpretation Date: Thu, 01 Feb 96 09:43:46 GMT Lines: 45 Message-ID: <823167826.snews.post.Gordon@apis.demon.co.uk> References: <4eads7$4e6 AT trog DOT dra DOT hmg DOT gb> <4eo169$5uo AT maya DOT dei DOT unipd DOT it> Reply-To: Gordon Scott To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In article <4eo169$5uo AT maya DOT dei DOT unipd DOT it> lupus AT tasha DOT dei DOT unipd DOT it "Molaro Paolo 338814/C (addetto" writes: > In article <4eads7$4e6 AT trog DOT dra DOT hmg DOT gb>, wrote: > >void term() > >{ > > switch (curr_tok) > > { > > case 1: > > double d = 3.0; > > break; > > default: > > return; > > } > >} > > > >..should fail to compile under djgpp v2 beta 4 with error messages... > > > >test.cc: In function `void term()': > >test.cc:11: jump to case label > >test.cc:9: crosses initialization of `double d' > > > >..but compile fine if I do not initialise d, and compile fine under > >djgpp 1.12m4 without alteration? > > > > I think you have to write something like this: > > case 1: { > double d = 3.0; > break; > } > ... That's correct, *BUT*, the variable is then only alive within the braces, which in the above case is probably useless. Declare the variable in a more suitable scope and then just assign to it in the case. -- Gordon Scott Gordon AT apis DOT demon DOT co DOT uk Compuserve 100332,3310 Gordon AT multitone DOT co DOT uk Basingstoke Beekeeper Beekeeper AT apis DOT demon DOT co DOT uk