------- 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

Reply via email to