From patchwork Fri Apr 4 19:20:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 337079 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5B92B14007B for ; Sat, 5 Apr 2014 06:22:12 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=REdvY2lOx6dLv0M34lSAXaMafuVEMVAwk6gRi8HNlTp L0wHCaqYM1M3y+bm3L6ElESMTs00gZkSPHuyV4rZWncH8yx3WaAwN365oPisZIHK tDe9wxvXU0DiKMW7CGQ/Dm6vJHNbnOL6/rmgJM28LlDDZa4x5DRN/+n7vZ35Opxg = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=BXNC/jE3K1ljI+7RPPCjnfowOzI=; b=OOIbCQnCHy/Cj762z 6R4mCE3SACY/rXQW7vpexlFkIn88AGO4u1BFYRL9WCf0ip+JTT2DAA9ELN9AiOQ0 +sIRB5DxisBmOYQrp/LUf+SPHM87BVUgV0+u9DF700rL8iGctOLtjrwb2i8WIkYT xin0Qz8dwegCcWRsVFX8fSWwQQ= Received: (qmail 29408 invoked by alias); 4 Apr 2014 19:22:05 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 29396 invoked by uid 89); 4 Apr 2014 19:22:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 04 Apr 2014 19:22:04 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s34JM04E011924 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 4 Apr 2014 19:22:01 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s34JLxga015462 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 4 Apr 2014 19:22:00 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s34JLx7g015059; Fri, 4 Apr 2014 19:21:59 GMT Received: from [192.168.1.4] (/79.52.211.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 04 Apr 2014 12:21:59 -0700 Message-ID: <533F060D.7060903@oracle.com> Date: Fri, 04 Apr 2014 21:20:45 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 58207 X-IsSubscribed: yes Hi, this regression is an ICE happening during error recovery: the loop in sort_constexpr_mem_initializers tries to access the vector beyond its end. Robustifying the whole thing, using in particular a standard pattern using vec_safe_iterate to go through the vector, works. In case, I'm not sure if we also want to add a gcc_assert on errorcount, maybe right before the final conditional?!? Booted and tested x86_64-linux. Thanks, Paolo. //////////////////// /cp 2014-04-04 Paolo Carlini PR c++/58207 * semantics.c (sort_constexpr_mem_initializers): Robustify loop. /testsuite 2014-04-04 Paolo Carlini PR c++/58207 * g++.dg/cpp0x/constexpr-ice15.C: New. Index: cp/semantics.c =================================================================== --- cp/semantics.c (revision 209078) +++ cp/semantics.c (working copy) @@ -7717,8 +7717,8 @@ sort_constexpr_mem_initializers (tree type, vec &vref = *v; - for (i = 0; ; ++i) - if (TREE_TYPE (vref[i].index) == field_type) + for (i = 0; vec_safe_iterate (v, i, &ce); ++i) + if (TREE_TYPE (ce->index) == field_type) break; - if (i > 0) + if (i > 0 && i < vec_safe_length (v)) { - elt = vref[i]; + vec &vref = *v; + constructor_elt elt = vref[i]; for (; i > 0; --i) vref[i] = vref[i-1]; vref[0] = elt; Index: testsuite/g++.dg/cpp0x/constexpr-ice15.C =================================================================== --- testsuite/g++.dg/cpp0x/constexpr-ice15.C (revision 0) +++ testsuite/g++.dg/cpp0x/constexpr-ice15.C (working copy) @@ -0,0 +1,12 @@ +// PR c++/58207 +// { dg-do compile { target c++11 } } + +struct A +{ + virtual bool foo (); +}; + +struct B : public A +{ + constexpr B () : A (&::n) {} // { dg-error "declared" } +};