mikeb@ee.ubc.ca (Mike Bolotski) (11/19/89)
I'm not sure if this is a g++ bug or a V2.0 feature. In any case, similar code worked fine under 1.35. The compiler complains about the jump past the initialization point. In this example, the goto can be replaced by a continue; in the actual application, the goto is used as a continue(3) equivalent (continue with loop 3 levels out), so no flames about goto's. Please. ----- Script started on Sat Nov 18 21:16:31 1989 coho{mikeb}101: g++ -v lambda.cc gcc version 1.36.1 (based on GCC 1.36) /usr/local/lib/gnu/gcc-cpp -+ -v -undef -D__GNUC__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 lambda.cc /usr/tmp/cca09073.cpp GNU CPP version 1.36 /usr/local/lib/gnu/gcc-cc1plus /usr/tmp/cca09073.cpp -quiet -dumpbase lambda.cc -version -o /usr/tmp/cca09073.s GNU C++ version 1.36.1 (based on GCC 1.36) (68k, MIT syntax) compiled by GNU C version 1.36. default target switches: -m68020 -mc68020 -m68881 -mbitfield lambda.cc: In function int main (): lambda.cc:14: invalid jump to label `nextp' lambda.cc:11: crosses initialization of `q' coho{mikeb}102: cat lambda.cc #include <stdio.h> int main() { for (int p = 100; p ; ) { if (p > 10) goto nextp; short q = 7 * p; if (q > 4) printf("Hello\n"); nextp: ; } } coho{mikeb}103: exit exit
tiemann@lurch.stanford.edu (Michael Tiemann) (11/19/89)
Date: 18 Nov 89 21:22 -0800 From: Mike Bolotski <mikeb@ee.ubc.ca> I'm not sure if this is a g++ bug or a V2.0 feature. In any case, similar code worked fine under 1.35. The compiler complains about the jump past the initialization point. In this example, the goto can be replaced by a continue; in the actual application, the goto is used as a continue(3) equivalent (continue with loop 3 levels out), so no flames about goto's. Please. ----- coho{mikeb}101: g++ -v lambda.cc [...] lambda.cc: In function int main (): lambda.cc:14: invalid jump to label `nextp' lambda.cc:11: crosses initialization of `q' coho{mikeb}102: cat lambda.cc #include <stdio.h> int main() { for (int p = 100; p ; ) { if (p > 10) goto nextp; short q = 7 * p; if (q > 4) printf("Hello\n"); nextp: ; } } coho{mikeb}103: exit exit It's a 2.0 feature. cfront 2.0 also gives an error: cfront < l5.cc > /dev/null "", line 9: error: goto nextp past initialized q teacake% Both compilers will let you use continue. If you want a work-around, just wrap `q' in a scope which makes it invisible at `nextp'. Michael