From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 5DBF93858D38 for ; Fri, 10 Nov 2023 00:28:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5DBF93858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5DBF93858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699576117; cv=none; b=G1GP4bzboDAZOR7gNGXr6EzD0dTO64RTxTssSgqlh0n2O7OMTsLRJyF/ef4WlWFkhBnWmHf8FspXywaaZIlvVVcrdyYRPZJhUWsyfbsXQlWx0X5pwnrOEuV0zT5aEFEGFS1v/IwAMndwi2DOI8/M0REkSWBECQBAQEV0GViiKcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699576117; c=relaxed/simple; bh=4Py3qtR7kkZLomBt4M09LmbpSzZLIBt9fQ2p7d3eTNA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=GEGqiHpm6sLgjJX4AeCgt+5QCT+8tjj9O002HxC5AJT9PCapAIBXzXfibuIJNY6TrNd3EApg7uVj4XFtENVGpOVoczW91TvdAZfQfg1NFxPCq1xiGh6IXR2w7B/q36gbO30iEkI+ixbiuogxkbW+nwriG8X5EyQ+TPP/9yDzaRs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699576115; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NFyltkGHtcd2VSyloamFpNM90Vo1chq2IvIhzbSdlO4=; b=QlqTE4gj2ZK4yROukRtm5oOt74yUzkJNEwjxl6k8YKttUoGYdDKYMLDaLZNJa9xzj8LwP2 CaXvLNdtdXmh8IjRWjEf9zspr2ejDw4aYCLDEMp7Z6k4DWDcb6Q+FH+NkRlYjTrt9v5FcK L/5x4nIqtRSjzsvlL2hwOiMQXUrra28= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-453-cQ1v784OPBGt1aBCPeH63w-1; Thu, 09 Nov 2023 19:28:34 -0500 X-MC-Unique: cQ1v784OPBGt1aBCPeH63w-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-41eaf5d20d8so18099521cf.3 for ; Thu, 09 Nov 2023 16:28:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699576114; x=1700180914; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NFyltkGHtcd2VSyloamFpNM90Vo1chq2IvIhzbSdlO4=; b=V415F0U9+PqQHEXBQkD6Cchp/R3N34jFGVVIU2zvIBbVrHHjIVbldLg34qjwO13eZe cHmNdSfrel3KPnDRiJEmXxbE30etvnG8U2GZNpMrQY63jJOOf8/judsonOC4LGtx6TZE U8iUXGTNaHlw52ZQdlwormjGDBt/Fs7Ds6QIfuzEOKh4Y8lEwuLm2358DtAhX7rU28av iQwVjusJnDWpNzlizBb2nNMSmIuCtE9+VWuX/cuZYQRI2BSYgtu/G1dyzvU8wd4XAMd1 veILTIjiu01hfzwneS/SutNhi72hHLofI7rEszjZUJ5mD3R3aTnYZu41QRjVjNuYBJut +5bQ== X-Gm-Message-State: AOJu0Yyzw3NJ53XQ3rN2uO6NLcuGwodW07i80uaGTnZ44xa5M4DHmtWI y91UbobtNdMtlONbmjl7funZsoGKbgUu90Au3oUW6CtLhpfUzuoZkOkvyU0QrBEWlmiQNtTD51R m+odLk1FWPN2IBokpVw== X-Received: by 2002:ac8:588f:0:b0:418:af7:e001 with SMTP id t15-20020ac8588f000000b004180af7e001mr6452798qta.41.1699576114020; Thu, 09 Nov 2023 16:28:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqaJ07yEM6JnwQWv18VsH7AX+Xo8AfglGcAs0Xz0zMJmmm1YJAzimBfYe7teqloqfEyP6iKA== X-Received: by 2002:ac8:588f:0:b0:418:af7:e001 with SMTP id t15-20020ac8588f000000b004180af7e001mr6452792qta.41.1699576113769; Thu, 09 Nov 2023 16:28:33 -0800 (PST) Received: from [192.168.1.108] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id v7-20020ac87487000000b0041815bcea29sm168936qtq.19.2023.11.09.16.28.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Nov 2023 16:28:33 -0800 (PST) Message-ID: <375a6726-8998-4b6b-830f-32852ef116b1@redhat.com> Date: Thu, 9 Nov 2023 19:28:32 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: non-dependent .* folding [PR112427] To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20231108215904.2779753-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20231108215904.2779753-1-ppalka@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham 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 11/8/23 16:59, Patrick Palka wrote: > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk? > > -- >8 -- > > Here when building up the non-dependent .* expression, we crash from > fold_convert on 'b.a' due to this (templated) COMPONENT_REF having an > IDENTIFIER_NODE instead of FIELD_DECL operand that middle-end routines > expect. Like in r14-4899-gd80a26cca02587, this patch fixes this by > replacing the problematic piecemeal folding with a single call to > cp_fully_fold. > > PR c++/112427 > > gcc/cp/ChangeLog: > > * typeck2.cc (build_m_component_ref): Use cp_convert, build2 and > cp_fully_fold instead of fold_build_pointer_plus and fold_convert. > gcc/testsuite/ChangeLog: > > * g++.dg/template/non-dependent29.C: New test. > --- > gcc/cp/typeck2.cc | 5 ++++- > gcc/testsuite/g++.dg/template/non-dependent29.C | 13 +++++++++++++ > 2 files changed, 17 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/g++.dg/template/non-dependent29.C > > diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc > index 309903afed8..208004221da 100644 > --- a/gcc/cp/typeck2.cc > +++ b/gcc/cp/typeck2.cc > @@ -2378,7 +2378,10 @@ build_m_component_ref (tree datum, tree component, tsubst_flags_t complain) > /* Build an expression for "object + offset" where offset is the > value stored in the pointer-to-data-member. */ > ptype = build_pointer_type (type); > - datum = fold_build_pointer_plus (fold_convert (ptype, datum), component); > + datum = cp_convert (ptype, datum, complain); > + datum = build2 (POINTER_PLUS_EXPR, ptype, > + datum, convert_to_ptrofftype (component)); We shouldn't need to build the POINTER_PLUS_EXPR at all in template context. OK with that change. Jason