From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 291FC3858D28 for ; Thu, 21 Mar 2024 15:27:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 291FC3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.crashing.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 291FC3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=63.228.1.57 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711034833; cv=none; b=OP+SObM2oTPl5UKgAekWwha3ZaT0/SDA/YXFTh2HXd3jKywva7qCUN1qDDSu1QqZwyAfen96SKJcUaiN0LSnFFXCuiF+KGOeHiaA3K/2kN+AENRWRvaKJUE5/12lstSEYWrtAuoJZXCGKBNt2Fs8oYGG+fFA0nX84JRObCgilRs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711034833; c=relaxed/simple; bh=dI1tkorwMtuqtKIFfvnFoJ4YS76x9bj99iDR9bIeX4s=; h=Date:From:To:Subject:Message-ID:Mime-Version; b=RWsMHmKHNNZEVYKs1rbiVMX54h75XssTNsMk1JLbuAdVqF+zRLsPYEbUjZ+uGX9cw9Pvos2PqJTrUae3U6CbPpqx3CUlXWGrsXl/qjltJ2VXDBXk67nbDnz9ONwyCP6Lk5OFrfgtYctiJLjJnteInvPXUoXjhmWJt2Mj7mhgYG8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 42LFQBDP011842; Thu, 21 Mar 2024 10:26:11 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 42LFQB2v011841; Thu, 21 Mar 2024 10:26:11 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Thu, 21 Mar 2024 10:26:11 -0500 From: Segher Boessenkool To: Centurion Cc: gcc-help@gcc.gnu.org Subject: Re: your mail Message-ID: <20240321152611.GC19790@gate.crashing.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Mar 21, 2024 at 07:12:23PM +0400, Centurion via Gcc-help wrote: > HI, I am new in gcc codebase. Can you explain please why we can't just use > TREE_TYPE(parm) for TEMLATE_TEMPLATE_PARM and why DECL_INITIAL is needed > for it? I tried to debug Bug 114377 and it seems to work fine. Thanks You cannot use TREE_TYPE if that would just access nonsense data. The wrong thing might still work, in many cases. If you have no substantiation why your proposed change would work fine, chances are it does not. Sorry. Segher > --- a/gcc/cp/pt.cc > +++ b/gcc/cp/pt.cc > @@ -11032,10 +11032,7 @@ find_template_parameter_info::found (tree parm) > { > if (TREE_CODE (parm) == TREE_LIST) > parm = TREE_VALUE (parm); > - if (TREE_CODE (parm) == TYPE_DECL) > - parm = TREE_TYPE (parm); > - else > - parm = DECL_INITIAL (parm); > + parm = TREE_TYPE(parm); > gcc_checking_assert (TEMPLATE_PARM_P (parm)); > return parms.contains (parm); > }