Mail Archives: djgpp/1996/02/01/14:50:38
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>, <itmiller AT taz 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
- Raw text -