From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14806 invoked by alias); 21 Jun 2010 16:51:28 -0000 Received: (qmail 14700 invoked by uid 48); 21 Jun 2010 16:51:06 -0000 Date: Mon, 21 Jun 2010 16:51:00 -0000 Message-ID: <20100621165106.14699.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/44613] Declaring an array with non-constant length inside a switch corrupts stack pointer. In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "manu at gcc dot gnu dot org" 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: 2010-06/txt/msg02080.txt.bz2 ------- Comment #4 from manu at gcc dot gnu dot org 2010-06-21 16:51 ------- (In reply to comment #3) > (In reply to comment #1) > > (In reply to comment #0) > > > The following program compiles with g++ -O3 without errors or warnings > > > > Not with warnings enabled it doesn't! > > > > Sorry, > > g++ -O3 -Wall -Wextra switch-crash.cpp gives: > > switch-crash.cpp: In function ‘int f(int)’: > switch-crash.cpp:6: warning: unused variable ‘x’ > switch-crash.cpp:10: warning: no return statement in function returning > non-void If you add return 0 after the printf, this warning is silenced and it still crashes (it crashes for me even at -O0). > switch-crash.cpp:7: warning: ‘saved_stack.1’ is used uninitialized in this > function > > The ‘saved_stack.1’ is somewhat suspicious. It is a bug anyway, because internal variables should never be warned. -- manu at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2010-06-21 16:51:06 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44613