From patchwork Wed Feb 14 14:53:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 873376 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-473272-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="NK+8pxmi"; dkim-atps=neutral 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 3zhMq328WGz9t3C for ; Thu, 15 Feb 2018 01:53:35 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=SErR296FN7hCpQvZKX14lEmd2ej9pQjvzgc5bp9WmaJEie5UjO 6ogfRfsWzIcFnmRIwG+STT4xAibcZPjURBDdYcWFklkor3ylmjV11rJN4W+7TTcA Sipxaz+s6uPeoSEoime1qZJt2j9uozOu4Xw2yXbxJMWl9FeH4SL70LtbU= 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:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=9ZmDzp31k9OsFsb3Ro4x+nkNz3s=; b=NK+8pxmiI5a0tq88BekW mSK24Tn09peTbAypDsenDOBcMiJuZ+Dy5VcRbfmui5AKil88mYs6BYOMrAsFykg8 6LPQzGCbqNbkcKrIZ8QzEF8HYhIl51wNBvGSaQMKO8+CXQTLssCF/qEj58684GxV nbZd541WSJSuxvYA8sAdWS4= Received: (qmail 67538 invoked by alias); 14 Feb 2018 14:53:28 -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 67529 invoked by uid 89); 14 Feb 2018 14:53:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_SHORT, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Feb 2018 14:53:25 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1EEqEM3100373; Wed, 14 Feb 2018 14:53:21 GMT Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2g4puq058t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Feb 2018 14:53:21 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w1EErKl1004553 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Feb 2018 14:53:21 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w1EErKOb032275; Wed, 14 Feb 2018 14:53:20 GMT Received: from [192.168.1.4] (/79.52.198.133) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 14 Feb 2018 06:53:19 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 84350 ("[7/8 Regression] ICE with new and auto") Message-ID: <5b3d0283-a419-ef28-cf5e-336c7622e754@oracle.com> Date: Wed, 14 Feb 2018 15:53:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8804 signatures=668670 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802140177 X-IsSubscribed: yes Hi, today I spent some time on this: basing on r245826, when we started ICEing. For example I wondered if we wanted to rework the use of do_auto_deduction from build_new, and check CLASS_PLACEHOLDER_TEMPLATE (auto_node) and possibly directly call do_class_deduction when d_init stays NULL_TREE because vec_safe_length (*init) != 1 ( https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/cp/init.c?r1=245826&r2=245825&pathrev=245826 ). But that would require a non-static do_class_deduction and an additional function call from build_new, not at all sure it's worth it. Thus I'm just proposing the below, restoring the old diagnostic and avoiding the ICE. Thanks, Paolo. //////////////// /cp 2018-02-14 Paolo Carlini PR c++/84350 * pt.c (do_auto_deduction): Don't check the TREE_TYPE of a null init, early return. /testsuite 2018-02-14 Paolo Carlini PR c++/84350 * g++.dg/cpp0x/auto49.C: New. Index: cp/pt.c =================================================================== --- cp/pt.c (revision 257659) +++ cp/pt.c (working copy) @@ -25975,7 +25975,7 @@ do_auto_deduction (tree type, tree init, tree auto /* C++17 class template argument deduction. */ return do_class_deduction (type, tmpl, init, flags, complain); - if (TREE_TYPE (init) == NULL_TREE) + if (init == NULL_TREE || TREE_TYPE (init) == NULL_TREE) /* Nothing we can do with this, even in deduction context. */ return type; Index: testsuite/g++.dg/cpp0x/auto49.C =================================================================== --- testsuite/g++.dg/cpp0x/auto49.C (nonexistent) +++ testsuite/g++.dg/cpp0x/auto49.C (working copy) @@ -0,0 +1,12 @@ +// PR c++/84350 +// { dg-do compile { target c++11 } } + +template void foo(T... t) +{ + new auto(t...); // { dg-error "invalid use" } +} + +void bar() +{ + foo(); +}