Xref: news2.mv.net comp.os.msdos.djgpp:959 From: bradtech AT i-link DOT net (Brad Burgan) Newsgroups: comp.os.msdos.djgpp Subject: Re: v2 vs v1 C++ interpretation Date: Tue, 06 Feb 1996 15:09:32 GMT Organization: I-Link Inc Lines: 52 Message-ID: <4f7qvi$10ca@news.i-link.net> References: <4eads7$4e6 AT trog DOT dra DOT hmg DOT gb> NNTP-Posting-Host: houston-1-1.i-link.net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp itmiller AT taz DOT dra DOT hmg DOT gb () wrote: >Does anyone know why the C++ function... > >void term(); >int curr_tok = 0; > >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... > >gcc -c test.cc >test.cc: In function `void term()': >test.cc:11: jump to case label >test.cc:9: crosses initialization of `double d' >make.exe: *** [test.o] Error 1 > >..but compile fine if I do not initialise d, and compile fine under >djgpp 1.12m4 without alteration? > Someone correct me if I'm wrong, but... gcc 2.7 uses some newer scoping rules that have required me changing my programs. For example... for (int i = 0; i < 3; i++) { foo(); } for (i = 3; i < 6; i++) { bar(); } this works with all other compilers I've used, including v112m4, but not with gcc272. It says the new ansi scoping doesn't allow this anymore. That's probably why it doesn't want you doing that.