From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 567 invoked by alias); 26 Mar 2013 15:56:11 -0000 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 Received: (qmail 548 invoked by uid 48); 26 Mar 2013 15:56:04 -0000 From: "ktietz at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/56742] New: Optimization bug lead to uncaught throw Date: Tue, 26 Mar 2013 15:56:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ktietz at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 X-SW-Source: 2013-03/txt/msg01918.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56742 Bug #: 56742 Summary: Optimization bug lead to uncaught throw Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: ktietz@gcc.gnu.org Target: x86_64-w64-mingw32, x86_64-pc-cygwin Hi, the following testcase: #include static int main_worker(int argc) { std::string s[32]; // [31] => no segfault if (argc < 2) throw 42; return argc; } int main(int argc, char **argv) { try { return main_worker(argc); } catch (int i) { return i; } } produces with optimization -O2 on execution the message: "terminate called after throwing an instance of 'int'" and abort gets called. If compiled with optimization level -O1, execution works as expected.