From patchwork Mon Dec 12 16:51:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 87721 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1744348qgi; Mon, 12 Dec 2016 08:52:11 -0800 (PST) X-Received: by 10.99.66.198 with SMTP id p189mr169466059pga.30.1481561531253; Mon, 12 Dec 2016 08:52:11 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id s136si44023329pgc.65.2016.12.12.08.52.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Dec 2016 08:52:11 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-444190-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-444190-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-444190-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com 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=jjQuQPEWckJsz5fcKv7cNtOSRes2++7/Bf+eWBpscZi9uA1298 cPZuzPjDvCAhVaApcz9Ch4zdU9h1oCylwN4n4zYp+/wddiGeH87rnX4Mbx9CH4TD DKVpbtIsSzWpEQOgGaIL7eO9CK2KC6cqCMcIcarHd9WhIv2j3bzf4ic0w= 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=bV/864vj7tyjp1b3QCVvNAZ+b8U=; b=SKUhzHraPdOfrzPeEdFa hMl8ac2bDk3tYiLL1u3Za5ZURnNQq1UOyddopIBSQDReRvWxSRC8W0BVnKPpYizW zwcAyOg1vmhGD5aEm1sQ5jZhu05ikJud1HZ9s0gRWrgdTgGeN/a6+TaXT3CNqiMA uP3VzZhnQl6oBPhnKdV0Vx0= Received: (qmail 85443 invoked by alias); 12 Dec 2016 16:51:58 -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 85431 invoked by uid 89); 12 Dec 2016 16:51:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=cpp1y, Hx-languages-length:1825, Reject, H*M:5534 X-HELO: mail-qk0-f179.google.com Received: from mail-qk0-f179.google.com (HELO mail-qk0-f179.google.com) (209.85.220.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Dec 2016 16:51:56 +0000 Received: by mail-qk0-f179.google.com with SMTP id x190so89003170qkb.0 for ; Mon, 12 Dec 2016 08:51:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version; bh=wO78xSwHtUHTqPQd16pECHkGd0nG8lzvj1UUK1AIe9U=; b=X83r3j0/oC/XKB3qn4kMicEjhIY9QIqFpy0O3ACJxngcKbRmGiP7/8wCgYR3/zbi+F pvBWVwBIluVSpHm2LBkf6CD61MuIfaSYpB25xdQeFpc4mrgHydq9LUbZ6TI0raUrg18S bHpr6grbptXXiCeX/VTYyNNPz8Cr/dQoiBWa18ipAUo9yExh0XCG2iUq/h0IwvsLQC+m KguMNfEcgZhCsnYOHBWk+i6vo4gMT5ejzTV88bgWs+SQ3TT6DHh3B1ZwuT3IowgGdRoI Ueu3JAdPCl63tTNMHcs+5dOGJ6U8EyQ92R8SbTKZP6jBCqt1QX77iCc1YqDbW12/8Mwv ILOQ== X-Gm-Message-State: AKaTC01HvQyVFg/+cYQJu96iQFSKK8qAK2xwgnNQtjiE6M49jNUAPTWvNJoK5dBMWjCSCQ== X-Received: by 10.55.176.131 with SMTP id z125mr75278569qke.286.1481561514818; Mon, 12 Dec 2016 08:51:54 -0800 (PST) Received: from [192.168.0.26] (97-124-188-210.hlrn.qwest.net. [97.124.188.210]) by smtp.gmail.com with ESMTPSA id 14sm26772135qtp.19.2016.12.12.08.51.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Dec 2016 08:51:54 -0800 (PST) To: Gcc Patch List , Jason Merrill From: Martin Sebor Subject: [PATCH] c++/78774 - [6/7 Regression] ICE in constexpr string literals and templates Message-ID: <9cdcd33a-b903-5534-0130-0e0d44b2bf7b@gmail.com> Date: Mon, 12 Dec 2016 09:51:52 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 X-IsSubscribed: yes The attached patch removes the unsafe assumption behind the ICE. Is this okay for both trunk and GCC 6? Thanks Martin PR c++/78774 - [6/7 Regression] ICE in constexpr string literals and templates gcc/cp/ChangeLog: PR c++/78774 * pt.c (convert_template_argument): Avoid assuming operand type is non-null since that of SCOPE_REF is not. gcc/testsuite/ChangeLog: PR c++/78774 * g++.dg/cpp1y/pr78774.C: New test. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 97d0b48..1d68fcc 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7375,9 +7375,11 @@ convert_template_argument (tree parm, /* Reject template arguments that are references to built-in functions with no library fallbacks. */ const_tree inner = TREE_OPERAND (val, 0); - if (TREE_CODE (TREE_TYPE (inner)) == REFERENCE_TYPE - && TREE_CODE (TREE_TYPE (TREE_TYPE (inner))) == FUNCTION_TYPE - && TREE_CODE (TREE_TYPE (inner)) == REFERENCE_TYPE + const_tree innertype = TREE_TYPE (inner); + if (innertype + && TREE_CODE (innertype) == REFERENCE_TYPE + && TREE_CODE (TREE_TYPE (innertype)) == FUNCTION_TYPE + && TREE_CODE (innertype) == REFERENCE_TYPE && 0 < TREE_OPERAND_LENGTH (inner) && reject_gcc_builtin (TREE_OPERAND (inner, 0))) return error_mark_node; diff --git a/gcc/testsuite/g++.dg/cpp1y/pr78774.C b/gcc/testsuite/g++.dg/cpp1y/pr78774.C new file mode 100644 index 0000000..c77032d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr78774.C @@ -0,0 +1,9 @@ +// PR c++/78774 - [6/7 Regression] ICE in constexpr string literals and +// templates +// { dg-do compile { target c++14 } } + +template struct ops { + template struct A; + template using explode = typename A<*Ptr>::join; +}; +template typename ops<'\0'>::explode::type a;