Thread View: gnu.g++.bug
2 messages
2 total messages
Started by Mike Bolotski
Sun, 19 Nov 1989 05:22
Gotos past local variable initialization
Author: Mike Bolotski
Date: Sun, 19 Nov 1989 05:22
Date: Sun, 19 Nov 1989 05:22
39 lines
1822 bytes
1822 bytes
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
Gotos past local variable initialization
Author: Michael Tiemann
Date: Sun, 19 Nov 1989 05:29
Date: Sun, 19 Nov 1989 05:29
49 lines
1794 bytes
1794 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads