From patchwork Mon Jun 11 12:15:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 164124 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 C95E11007D1 for ; Mon, 11 Jun 2012 22:16:12 +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=1340021774; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=9HovoHMy2UQ56m+zH8DF CUaAv8s=; b=Rdc1iDpEFTNNyiY1PKh7vHUMicAK+noZPC+4YMXSSFqoeFiMXB6V 0gg3nelRmT0ut1szpUXv6aqGEyQRTc5MdW+NHPW1Ig2bUeDwovytnRCtR4Z4jFkt /slmNbxwh47Am9sLhf5Y9frE1tsZYWLAMfVCOqXi3a40YzM4J1S1BJE= 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:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=CidhTf+rAIh4zVMtGToJizmhakzyf/YDCYpLF+Znfer3hReCAnAnRQKgvv/gtk 707hDom/p7CT3H3Pv+oAhz8BYLOGztyDXlCPDNNUfpDQwGUDmyPqYn8VXIK2y+q0 s/kxWchAe99vto96wmCjdttIuUp0SWMhmAisv4LUAWzLQ=; Received: (qmail 3073 invoked by alias); 11 Jun 2012 12:16:09 -0000 Received: (qmail 3065 invoked by uid 22791); 11 Jun 2012 12:16:07 -0000 X-SWARE-Spam-Status: No, hits=-5.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Jun 2012 12:15:54 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id A6E6F8C061; Mon, 11 Jun 2012 14:15:53 +0200 (CEST) Date: Mon, 11 Jun 2012 14:15:53 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com Subject: [PATCH][C++] Fix PR53605 Message-ID: MIME-Version: 1.0 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 I changed empty arrays domain to use a signed sizetype [0, -1] domain mangling of a empty-array-type broke because mangling adds an unsigned one to the signed -1 which causes an ICE (I chose to do that instead of shifting the range to [1, 0] because much more code relies on a zero lower bound ...). The following fixes that by using double-ints for the arithmetic and thus also does not generate a not needed tree node. Bootstrapped and tested on x86_64-unknown-linux-gnu, ok? Thanks, Richard. 2012-06-11 Richard Guenther PR c++/53616 * mangle.c (write_array_type): Use double-ints for array domain arithmetic. * g++.dg/ext/pr53605.C: New testcase. Index: gcc/cp/mangle.c =================================================================== --- gcc/cp/mangle.c (revision 188384) +++ gcc/cp/mangle.c (working copy) @@ -3119,8 +3119,10 @@ write_array_type (const tree type) { /* The ABI specifies that we should mangle the number of elements in the array, not the largest allowed index. */ - max = size_binop (PLUS_EXPR, max, size_one_node); - write_unsigned_number (tree_low_cst (max, 1)); + double_int dmax + = double_int_add (tree_to_double_int (max), double_int_one); + gcc_assert (double_int_fits_in_uhwi_p (dmax)); + write_unsigned_number (dmax.low); } else { Index: gcc/testsuite/g++.dg/ext/pr53605.C =================================================================== --- gcc/testsuite/g++.dg/ext/pr53605.C (revision 0) +++ gcc/testsuite/g++.dg/ext/pr53605.C (revision 0) @@ -0,0 +1,16 @@ +// { dg-do compile } + +// Avoid -pedantic-error default +// { dg-options "" } + +template +class EqHelper { +public: + template + static int Compare( const T1& expected, + const T2& actual); +}; +void foo(){ + static const int kData[] = {}; + ::EqHelper::Compare(kData, "abc"); +}