From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6217 invoked by alias); 10 Jan 2014 13:21:15 -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 6173 invoked by uid 48); 10 Jan 2014 13:21:11 -0000 From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/58585] [4.9 Regression] ICE in ipa with virtual inheritance Date: Fri, 10 Jan 2014 13:21: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: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: hubicka 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: 2014-01/txt/msg01089.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58585 --- Comment #20 from Jan Hubicka --- Looking even deeper, there are two problems. The first is that we miss C in type hiearchy graph. C however may be defined in other unit. We do mistake already while walking B. There are two variants of B::foo. One when base A is non-virtual and other when it is virtual. B's vtable is: _ZTV1C: .quad 0 .quad 8 .quad 8 .quad 0 .quad _ZTI1C .quad _ZTv0_n24_N1B3fooEv .quad -8 .quad 0 .quad -8 .quad _ZTI1C .quad _ZN1B3fooEv Our walking logic misses the fact that descendands of B may use the thunk instead of FOO based on presence of virtual inheritance. I suppose for complete correctness I would have to add code associating methods with their virtual thunks and lookup the thunks when walking B and knowng that I am interested in the derived types. Simpler solution solving both problems practically is probably to simply walk known vtables and insert their types to the type hiearchy: all internal devirtualizations will be correct and all the missed calls to thunk from vtable of type defined externally are harmless: the visibility code already makes all the assumption that the call can happen.