From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14590 invoked by alias); 20 Dec 2013 19:22:44 -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 14502 invoked by uid 48); 20 Dec 2013 19:22:40 -0000 From: "law at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/57904] [4.9 Regression] Bogus(?) "invokes undefined behavior" warning with Fortran's finalization wrapper (gfortran.dg/class_48.f90) Date: Fri, 20 Dec 2013 19:22:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: law at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-12/txt/msg01956.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57904 --- Comment #14 from Jeffrey A. Law --- So a quick prototype which reuses the infrastructure from the phi-only-propagator cleans things up quite nicely. Given this block after substitute_and_fold does its thing: : ubound.0_3 = 0; size.1_4 = ubound.0_3 + 1; size.1_5 = MAX_EXPR ; _6 = size.1_5 * 4; _7 = (character(kind=4)) _6; _8 = MAX_EXPR <_7, 1>; sizes_9 = __builtin_malloc (_8); size.3_10 = MAX_EXPR ; _11 = size.3_10 * 4; _12 = (character(kind=4)) _11; _13 = MAX_EXPR <_12, 1>; strides_14 = __builtin_malloc (_13); MEM[(integer(kind=4)[0:D.1917] *)sizes_9][0] = 1; if (ubound.0_3 > 0) goto ; else goto ; I (manually) seed the phi-only propagator's 2nd step with _3 as being a newly exposed destination of a copy/constant initialization and let that trivial propagator do its thing... Resulting in: : sizes_9 = __builtin_malloc (4); strides_14 = __builtin_malloc (1); MEM[(integer(kind=4)[0:D.1917] *)sizes_9][0] = 1; goto ; Which is exactly what we want. Also note that we collapse the conditional at the end of the block. That in turn makes the problematic loop unreachable and it goes away as one would expect. The problem I see is I'd prefer not to expose this in substitute_and_fold directly. That routine is used by multiple propagators. I'm thinking that instead we can have a callback to the pass utilizing substitute_and_fold that gets called when something has folded.