🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #599

Gotos past local variable initialization

#599
From: Mike Bolotski
Date: Sun, 19 Nov 1989 05:22
39 lines
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
Technical Details
Message-ID: <285*mikeb@ee.ubc.ca>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!jarvis.csri.toronto.edu!rutgers!mit-eddie!snorkelwacker!tut.cis.ohio-state.edu!ee.ubc.ca!mikeb

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!jarvis.csri.toronto.edu!rutgers!mit-eddie!snorkelwacker!tut.cis.ohio-state.edu!ee.ubc.ca!mikeb
From: mikeb@ee.ubc.ca (Mike Bolotski)
Newsgroups: gnu.g++.bug
Subject: Gotos past local variable initialization
Message-ID: <285*mikeb@ee.ubc.ca>
Date: 19 Nov 89 05:22:00 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 39