From patchwork Mon Feb 15 19:38:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 583070 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 2374C140271 for ; Tue, 16 Feb 2016 06:38:35 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=CZkI6ocn; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=XXz7kQuTk0H/llO6dtCYANc3NOjV+MBFnXTVLJ6j76kr3JJ2kR s99nkDOnI5irtIGKhWU+dDDdNGrFdWz5TnC5AuRbCuTPWn0bgUCL0OrfnTHXmAQC JN0EN1Yw84pE1Xvlfltu8fmUtt2n1sZxdpCQJBlhvv/iyWqga96417mcY= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=EWmvu1s320yh38kCafh8GHzgGu4=; b=CZkI6ocnKh6qe1S4+9CU aWUJ7ZmM7XxE0KEU3sSW8wh+OT04rDtigBqYagr5f6B+s1f+nYiI+4vGqy1wv76Q 7P4CZ14l84rWnze3Affgax6Q1XLdceIaj7O4NL4m5HoerIGzWuXQxRgPBKvTN3Ys vmTrO1o+geLeyjk82iAblTw= Received: (qmail 125291 invoked by alias); 15 Feb 2016 19:38:27 -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 125259 invoked by uid 89); 15 Feb 2016 19:38:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=CONSTRUCTOR, _type, HX-Envelope-From:sk:jason@r, Hx-languages-length:1878 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 15 Feb 2016 19:38:25 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 75438C0C2356 for ; Mon, 15 Feb 2016 19:38:24 +0000 (UTC) Received: from [10.10.116.56] (ovpn-116-56.rdu2.redhat.com [10.10.116.56]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1FJcNoI031665 for ; Mon, 15 Feb 2016 14:38:24 -0500 To: gcc-patches List From: Jason Merrill Subject: C++ PATCH for c++/68890 (ICE with constexpr value-initialization) Message-ID: <56C2292F.4000906@redhat.com> Date: Mon, 15 Feb 2016 14:38:23 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 Here, my assertion that a CONSTRUCTOR should be empty when we start to give it an initial value was forgetting about the case of classes with non-user-defined constructors, where value-initialization first zero-initializes, then calls the synthesized constructor. Tested x86_64-pc-linux-gnu, applying to trunk and 5. commit c87b2db1a8bff1394c5e607f8d470f5eed20193c Author: Jason Merrill Date: Wed Feb 10 21:17:52 2016 -0500 PR c++/68990 * constexpr.c (verify_ctor_sanity): Remove CONSTRUCTOR_NELTS check. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 85fc64e..11037fb 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -2202,7 +2202,8 @@ verify_ctor_sanity (const constexpr_ctx *ctx, tree type) gcc_assert (ctx->ctor); gcc_assert (same_type_ignoring_top_level_qualifiers_p (type, TREE_TYPE (ctx->ctor))); - gcc_assert (CONSTRUCTOR_NELTS (ctx->ctor) == 0); + /* We used to check that ctx->ctor was empty, but that isn't the case when + the object is zero-initialized before calling the constructor. */ if (ctx->object) gcc_assert (same_type_ignoring_top_level_qualifiers_p (type, TREE_TYPE (ctx->object))); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-value5.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-value5.C new file mode 100644 index 0000000..8c67174 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-value5.C @@ -0,0 +1,18 @@ +// PR c++/68990 +// { dg-do compile { target c++11 } } + +class ptr; +template struct A { typedef ptr _Type[_Nm]; }; +template struct B { typename A<_Nm>::_Type _M_elems; }; +template class FixedVector : B { +public: + typedef B<1> base; + constexpr FixedVector() : base(), size_() {} + char size_; +}; +class ptr { +public: + constexpr ptr() : px_(){}; + int px_; +}; +FixedVector<1> a;