From patchwork Mon Oct 30 13:52:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 832035 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-465471-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="FRpMwNxY"; 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 3yQbXF0gj1z9t1G for ; Tue, 31 Oct 2017 00:52:43 +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=WIFv2sRYWgvV1JO5F5Pl06/BDdr2vQiSAH0mV8O4uXo4XiHPTT q9+jkvQoXxZw6fzI7xoQ/S4MsyDLh40Gflwr00TzuNvzU/Zdf1R3ZJ7t+D/gJPb6 95hyYDHK2bPzy8VMBuxdCCGfun0ApRJbiJZMfmMKsz0NGR5+MbLnfaY4I= 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=yUKYerP4sh/icK932v3HWAGJKt8=; b=FRpMwNxYrOxHy7q20Glm BrB/9Sc3rIAwiMooSrSclGUf2r4JoPjxdJjNkgo3nQKFcv/dkfazbrQfHwfBFbWd q3YWIYQFcN8DvXQB2ZUSsm+XPXJaGuqqxzf04FmD0RUXgiH1AJWtn8ns7mItUN67 TWdUmTqVsoONBD6zlOr4FX8= Received: (qmail 56493 invoked by alias); 30 Oct 2017 13:52:29 -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 55358 invoked by uid 89); 30 Oct 2017 13:52:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*r:ip*192.168.1.4, Hx-spam-relays-external:192.168.1.4, H*RU:192.168.1.4, funny X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Oct 2017 13:52:27 +0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v9UDqOaA016059 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Oct 2017 13:52:25 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v9UDqO0v007392 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Oct 2017 13:52:24 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v9UDqNpC003301; Mon, 30 Oct 2017 13:52:24 GMT Received: from [192.168.1.4] (/82.61.149.169) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 30 Oct 2017 06:52:23 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch/RFC] PR 82085 ("[6/7/8 Regression] ICE: Template variable reference used in nested template alias") Message-ID: Date: Mon, 30 Oct 2017 14:52:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, lately I spent quite a bit of time triaging and resolving ICEs and noticed this recently filed regression which, in a wicked way, I find somehow funny. In short, we are seeing an ICE in tsubst_copy_and_build, when, for an INDIRECT_REF, TREE_TYPE (r) is found null: case INDIRECT_REF:    {     tree r = RECUR (TREE_OPERAND (t, 0));     if (REFERENCE_REF_P (t))       {         /* A type conversion to reference type will be enclosed in            such an indirect ref, but the substitution of the cast            will have also added such an indirect ref.  */         if (TREE_CODE (TREE_TYPE (r)) == REFERENCE_TYPE)           r = convert_from_reference (r); Since Jason's r226642, which fixed a serious issue with multiple Bugzillas, we have lookup_template_variable doing:   /* The type of the expression is NULL_TREE since the template-id could refer      to an explicit or partial specialization. */   tree type = NULL_TREE; instead of setting type = unknown_type_node and that ultimately leads to the ICE for the testcase at issue. Now, I found in a way funny that the body of convert_from_reference has: tree convert_from_reference (tree val) {   if (TREE_TYPE (val)       && TREE_CODE (TREE_TYPE (val)) == REFERENCE_TYPE) thus, if only somebody had cleaned up with no functionality change the above bits of tsubst_copy_and_build to unconditionally call convert_from_reference we would not have PR82085. Or at least we would not have it in this form, maybe we are only uncovering a much deeper issue?!? Anyway, the trivial patchlet below certainly passes testing on x86_64-linux. What do you think? Thanks, Paolo. ///////////////////// Index: cp/pt.c =================================================================== --- cp/pt.c (revision 254198) +++ cp/pt.c (working copy) @@ -17079,8 +17079,7 @@ tsubst_copy_and_build (tree t, /* A type conversion to reference type will be enclosed in such an indirect ref, but the substitution of the cast will have also added such an indirect ref. */ - if (TREE_CODE (TREE_TYPE (r)) == REFERENCE_TYPE) - r = convert_from_reference (r); + r = convert_from_reference (r); } else r = build_x_indirect_ref (input_location, r, RO_UNARY_STAR, Index: testsuite/g++.dg/cpp1y/var-templ56.C =================================================================== --- testsuite/g++.dg/cpp1y/var-templ56.C (nonexistent) +++ testsuite/g++.dg/cpp1y/var-templ56.C (working copy) @@ -0,0 +1,11 @@ +// PR c++/82085 +// { dg-do compile { target c++14 } } + +template +using char_sequence_t = int; + +template +constexpr char name_of_v = 'x'; + +template +using type = char_sequence_t>;