From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32123 invoked by alias); 2 Oct 2008 13:57:58 -0000 Received: (qmail 30371 invoked by uid 48); 2 Oct 2008 13:56:33 -0000 Date: Thu, 02 Oct 2008 13:57:00 -0000 Message-ID: <20081002135633.30370.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/28031] [4.2 regression] bogus jump to case label crosses initialization error with C99 anonymous initializers In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "cvoica at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-10/txt/msg00163.txt.bz2 ------- 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 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 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