From patchwork Sat Nov 24 03:24:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 201436 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 109792C007E for ; Sat, 24 Nov 2012 14:25:07 +1100 (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=1354332308; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=0LwzzTAPdNOQ/YxXhAFCSVAj7ms=; b=mY5ZDDwdil6/E5Z WbDeiKhYXsgnNjQKpztM6CXkNHJQac1CTxOjUXNk6UGZkxtNEbHZHsZ/Uo/Qv2Sx SU5CCapE/2LA1RNhTUcVtde+QiW/i8mwABq4VeC0z4DkqQGpuyN3bNkXtqfQkoDb whjo0rczwwpgeOZtKxAvot5PFXNY= 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:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ScIHp9J11mVFvxQ/kVaNI4J4sxO346yvef5xtQ8QfVUmSew6D5CagtVop+Dcfj ju7nqfce1eSc3PuzzfOiYvn5PHhzuqMd52aqGABim1L+FkYUbUzDRNdieUHLkIo7 aF2eWRDoT2opV6AAFbXFtrdKIpatXTRz48FiC1NFu8+M8=; Received: (qmail 18342 invoked by alias); 24 Nov 2012 03:25:01 -0000 Received: (qmail 18334 invoked by uid 22791); 24 Nov 2012 03:24:59 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL, BAYES_00, FSL_NEW_HELO_USER, RCVD_IN_HOSTKARMA_NO, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 24 Nov 2012 03:24:53 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id qAO3OpbW024245 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 24 Nov 2012 03:24:52 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id qAO3OpLr008083 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 24 Nov 2012 03:24:51 GMT Received: from abhmt115.oracle.com (abhmt115.oracle.com [141.146.116.67]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id qAO3OofN021226; Fri, 23 Nov 2012 21:24:50 -0600 Received: from [192.168.1.4] (/79.52.211.78) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 23 Nov 2012 19:24:50 -0800 Message-ID: <50B03E00.70409@oracle.com> Date: Sat, 24 Nov 2012 04:24:48 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121025 Thunderbird/16.0.2 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 55446 X-IsSubscribed: yes 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 Hi, this is a wrong code regression unfortunately caused by my fix for c++/45385. The story went (*) that in order to fix the latter missing warning we decided to remove the kludge added in c++/35602 to avoid a bogus warning *and* we also decided to early return from build_vec_init when maxindex is integer_all_onesp. Unfortunately the latter change caused the regression at issue, because we want to exactly use integer_all_onesp for perfectly valid things like: new S[0] At first, before I figured out the whole story, I thought we could solve the problem by simply doing nothing in case of 0 but then we don't reject a private default constructor for S. Using integer_zero_node or any other normal value is also not Ok, because it means the default constructor is actually called at least once. It seems we really want the special value to go through build_vec_init as it used to up to 4.6.x. Note that, currently at least, for the testcase added for c++/35602 build_vec_init is *not* used at all thus it can't possibly regress. Tested x86_64-linux. Thanks, Paolo. (*) http://gcc.gnu.org/ml/gcc-patches/2011-10/msg01946.html /cp 2012-11-23 Paolo Carlini PR c++/55446 * init.c (build_vec_init): Do not early return error_mark_mode when integer_all_onesp (maxindex). /testsuite 2012-11-23 Paolo Carlini PR c++/55446 * g++.dg/init/new41.C: New. Index: cp/init.c =================================================================== --- cp/init.c (revision 193775) +++ cp/init.c (working copy) @@ -3283,8 +3283,7 @@ build_vec_init (tree base, tree maxindex, tree ini if (TREE_CODE (atype) == ARRAY_TYPE && TYPE_DOMAIN (atype)) maxindex = array_type_nelts (atype); - if (maxindex == NULL_TREE || maxindex == error_mark_node - || integer_all_onesp (maxindex)) + if (maxindex == NULL_TREE || maxindex == error_mark_node) return error_mark_node; if (explicit_value_init_p) Index: testsuite/g++.dg/init/new41.C =================================================================== --- testsuite/g++.dg/init/new41.C (revision 0) +++ testsuite/g++.dg/init/new41.C (working copy) @@ -0,0 +1,22 @@ +// PR c++/55446 +// { dg-do run } + +struct S +{ + S() { } +}; + +int n = 1; + +void* operator new[](__SIZE_TYPE__) +{ + n = -1; + return &n; +} + +int main() +{ + new S[0]; + if (n != -1) + __builtin_abort(); +}