From patchwork Fri Apr 13 19:30:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 152388 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]) by ozlabs.org (Postfix) with SMTP id 900EAB7012 for ; Sat, 14 Apr 2012 05:31:23 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1334950284; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=dmK9p+v KyW+GUTlP2Q/WQtb2dTk=; b=JlSZa+ZKg1yFEjWlU4CeQOGP2NgMa2oGibmg08X EXOf6zobnvzMYGUci8u2DUtC/xFKXQgSnpPG4hDZV36RqCMfLHT0qV1RMKeinfVG lKDf3a+p/iqvgijKJ5IjcB3sqKFKB+Dq+JbwOSqbSuG+LpP6iDGyIyfmEk21Vlz2 nCHE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=NoNp6ArCDuC7rT3lcESLPgPf9S4nrAs8mMHkw4QKqzrpThKsfIvSylb+EmaZEH 7WGp9dL83NFdkwxLWU3HMU0V3puRte9SqyGElWRAzn5l6OiZcmwJ7VlaA/beZ9gC kyYa+hJfah3gQokj3v1DGDUllggn+hQrRtFYQWfoW83cw=; Received: (qmail 19401 invoked by alias); 13 Apr 2012 19:31:15 -0000 Received: (qmail 19159 invoked by uid 22791); 13 Apr 2012 19:31:12 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 13 Apr 2012 19:30:53 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3DJUqpX020665 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Apr 2012 15:30:53 -0400 Received: from [10.3.113.125] (ovpn-113-125.phx2.redhat.com [10.3.113.125]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q3DJUqpp009584 for ; Fri, 13 Apr 2012 15:30:52 -0400 Message-ID: <4F887EE7.3000808@redhat.com> Date: Fri, 13 Apr 2012 15:30:47 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/52905 (ICE with invalid list-initialization) 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 When a list-initialization doesn't quite match either a list constructor or a non-list constructor, we end up trying to compare them in joust and get confused because they have different numbers of parameters. So let's just treat them as unordered; we're going to talk about what's wrong with both of them anyway. Tested x86_64-pc-linux-gnu, applying to trunk. commit fad09b389b18d6f375b07bb680abc7e4590ecae2 Author: Jason Merrill Date: Fri Apr 13 13:01:59 2012 -0400 PR c++/52905 * call.c (joust): Handle comparing list and non-list ctors. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 3c3dabb..46ac55c 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -8011,6 +8011,12 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn) int static_1 = DECL_STATIC_FUNCTION_P (cand1->fn); int static_2 = DECL_STATIC_FUNCTION_P (cand2->fn); + if (DECL_CONSTRUCTOR_P (cand1->fn) + && is_list_ctor (cand1->fn) != is_list_ctor (cand2->fn)) + /* We're comparing a near-match list constructor and a near-match + non-list constructor. Just treat them as unordered. */ + return 0; + gcc_assert (static_1 != static_2); if (static_1) diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-ctor1.C b/gcc/testsuite/g++.dg/cpp0x/initlist-ctor1.C new file mode 100644 index 0000000..82031cb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-ctor1.C @@ -0,0 +1,13 @@ +// PR c++/52905 +// { dg-options -std=c++11 } + +#include + +enum E { e1, e2 }; +struct A +{ + A(std::initializer_list); // { dg-message "A::A" } + A(int, E); // { dg-message "A::A" } +}; + +A a{e1,2}; // { dg-error "" }