From patchwork Fri Jan 13 22:58:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 715293 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v0dMp1vLPz9vFF for ; Sat, 14 Jan 2017 09:58:28 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="QMwMZ0Um"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=xjTfYIqg+4Qu8fdWj Kt0741zlYsAk8UWmOO7qH0BZiCg2WRMYImSVBGaCmnxe5GWu9uyTBG5dgEMfwdPp EOcwSJgL8bDCfc/do5SOdldaXxaX3Y4KzoN8DkBNy7XhkoFTjA1hg4FMQdc+Nuql jsXM/PESHI8m0V6qgipPvdrsDI= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=zxkIfWYxXQ/D+eecFVkDmaw C80s=; b=QMwMZ0Umn5cgf2sjgLz6zteijUv8PSwlOb/s1EM03dcsHlyJPtW1hKa aj+c6uWGmDNW0ioSrKgjMS7Gr2oezIVtA6sNwci2YQVdJ/E5u0V1QCnWlzC+BePQ tnUVsUB8/xuwSr1Pijcmaf1SZPW2RdBxfSfEznc7M1oub+9RQcSQ= Received: (qmail 87224 invoked by alias); 13 Jan 2017 22:58:21 -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 86609 invoked by uid 89); 13 Jan 2017 22:58:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.3 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=H*f:sk:bc5274b, H*MI:sk:kyV1AYC, H*i:sk:mYtBqYd, H*MI:sk:mYtBqYd X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Jan 2017 22:58:10 +0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v0DMw6Kg017563 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 13 Jan 2017 22:58:07 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v0DMw6Wc015931 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 13 Jan 2017 22:58:06 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v0DMw6iH024709; Fri, 13 Jan 2017 22:58:06 GMT Received: from [192.168.1.4] (/87.11.227.37) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 13 Jan 2017 14:58:05 -0800 Subject: Re: [C++ Patch] PR 71737 To: Jason Merrill References: <5ed6bbe9-412f-b0da-a919-6a77add0dda3@acm.org> Cc: Nathan Sidwell , "gcc-patches@gcc.gnu.org" From: Paolo Carlini Message-ID: <66a1c9fb-3e86-1556-5804-7a8abcd448f4@oracle.com> Date: Fri, 13 Jan 2017 23:58:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: X-IsSubscribed: yes Hi, On 13/01/2017 18:33, Jason Merrill wrote: > On Fri, Jan 13, 2017 at 11:42 AM, Paolo Carlini > wrote: >> Hi, >> >> On 13/01/2017 15:51, Nathan Sidwell wrote: >>> On 01/13/2017 09:45 AM, Paolo Carlini wrote: >>>> Hi, >>>> >>>> in this error recovery issue get_underlying_template crashes when >>>> TYPE_TEMPLATE_INFO_MAYBE_ALIAS is applied to a null orig_type. Simply >>>> checking for that condition appears to solve the issue in a >>>> straightforward way. Tested x86_64-linux. >>> >>> Wouldn't it be better if a scrogged alias got error_mark_node as the >>> underlying type? (I have no idea whether that's an easy thing to >>> accomplish) >> Your reply, Nathan, led me to investigate where exactly DECL_ORIGINAL_TYPE >> becomes null, and turns out that in tsubst_decl we have code actively doing >> that. That same code, a few lines below, only sets TYPE_DEPENDENT_P_VALID to >> false if type != error_mark_node. I cannot say to fully understand yet all >> the details, but certainly the patchlet below also passes testing. Do you >> have comments about this too? > The clearing of DECL_ORIGINAL_TYPE is to allow set_underlying_type to > then set it to something more appropriate. That function currently > avoids setting DECL_ORIGINAL_TYPE to error_mark_node, perhaps that > should be changed. I see, thanks a lot. The below passes testing on x86_64-linux. Paolo. /////////////////////// Index: c-family/c-common.c =================================================================== --- c-family/c-common.c (revision 244405) +++ c-family/c-common.c (working copy) @@ -7419,16 +7419,18 @@ set_underlying_type (tree x) if (TYPE_NAME (TREE_TYPE (x)) == 0) TYPE_NAME (TREE_TYPE (x)) = x; } - else if (TREE_TYPE (x) != error_mark_node - && DECL_ORIGINAL_TYPE (x) == NULL_TREE) + else if (DECL_ORIGINAL_TYPE (x) == NULL_TREE) { tree tt = TREE_TYPE (x); DECL_ORIGINAL_TYPE (x) = tt; - tt = build_variant_type_copy (tt); - TYPE_STUB_DECL (tt) = TYPE_STUB_DECL (DECL_ORIGINAL_TYPE (x)); - TYPE_NAME (tt) = x; - TREE_USED (tt) = TREE_USED (x); - TREE_TYPE (x) = tt; + if (tt != error_mark_node) + { + tt = build_variant_type_copy (tt); + TYPE_STUB_DECL (tt) = TYPE_STUB_DECL (DECL_ORIGINAL_TYPE (x)); + TYPE_NAME (tt) = x; + TREE_USED (tt) = TREE_USED (x); + TREE_TYPE (x) = tt; + } } } Index: testsuite/g++.dg/cpp0x/pr71737.C =================================================================== --- testsuite/g++.dg/cpp0x/pr71737.C (revision 0) +++ testsuite/g++.dg/cpp0x/pr71737.C (working copy) @@ -0,0 +1,13 @@ +// PR c++/78765 +// { dg-do compile { target c++11 } } + +template