This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/28031] [4.2 regression] bogus jump to case label crosses initialization error with C99 anonymous initializers
- From: "cvoica at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Oct 2008 13:56:33 -0000
- Subject: [Bug c++/28031] [4.2 regression] bogus jump to case label crosses initialization error with C99 anonymous initializers
- References: <bug-28031-12387@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from cvoica at gmail dot com 2008-10-02 13:56 -------
I was trying to compile some code and got this error and thats how I found this
bug.
It seems strange to me that I cannot use a switch within a case branch and the
use the plain std::string.
Testcase:
1. This is working:
#include<iostream>
using namespace std;
int main(){
int i =0;
switch(i){
case 0:
break;
case 1:
string s;
break;
}
return 0;
}
ws6-126:~cvo> g++ switchtest.cxx
ws6-126:~cvo> g++ --version
g++ (GCC) 4.2.1 (SUSE Linux)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2. This is not working:
#include<iostream>
using namespace std;
int main(){
int i =0;
switch(i){
case 0:
int j=0;
switch(j){
case 0:
break;
}
break;
case 1:
string s;
break;
}
return 0;
}
ws6-126:~cvo> g++ switchtest.cxx
switchtest.cxx: In function ?int main()?:
switchtest.cxx:14: error: jump to case label
switchtest.cxx:8: error: crosses initialization of ?int j?
--
cvoica at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |cvoica at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28031