From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15763 invoked by alias); 27 Mar 2013 09:40:25 -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 15723 invoked by uid 48); 27 Mar 2013 09:40:18 -0000 From: "ktietz at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/56742] Optimization bug lead to uncaught throw Date: Wed, 27 Mar 2013 09:40:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: ktietz at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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/msg01971.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56742 --- Comment #4 from Kai Tietz 2013-03-27 09:40:16 UTC --- (In reply to comment #3) > (In reply to comment #2) > > Hmm, yes indeed it is the -freorder-blocks option. One solution is to > > disallow after reload for SEH-target to modify jumps. > > That's an awfully big hammer. Perhaps it's possible to first analyze > what is actually happening in bbreorder that causes this bug? Well, the issue is analyzed. The issue is that SEH is table-based EH, and so after bb-reorder used labels for describing eh-regions are getting invalid. If you take a look to the produces assembly for the example, you will notice that easily. I admit that the first patch is a bit too invasive, as it disables bb-reorder in all cases. But in fact we need to disable it just if there is a catch-region. A more improved variant is: Index: i386.c =================================================================== --- i386.c (Revision 197118) +++ i386.c (Arbeitskopie) @@ -3941,6 +3941,20 @@ register_pass (&insert_vzeroupper_info); } +/* Implement TARGET_CANNOT_MODIFY_JUMPS_P. */ +static bool +ix86_cannot_modify_jumps_p (void) +{ + if (TARGET_SEH && reload_completed + && cfun && cfun->eh + && cfun->eh->region_tree) + return true; + return false; +} + +#undef TARGET_CANNOT_MODIFY_JUMPS_P +#define TARGET_CANNOT_MODIFY_JUMPS_P ix86_cannot_modify_jumps_p + /* Update register usage after having seen the compiler flags. */ static void