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 560D03858C3A for ; Fri, 10 Nov 2023 15:13:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 560D03858C3A 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 560D03858C3A 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=1699629182; cv=none; b=J4FChr/3ajh5kzFduSuctbFGo+ZRsnICK+po8c6BZr2IYPBNwKEWLY9Lz0gnasLcrNjUQKivClEB3jDgZMMj7Q149n8dh6G0sgbVx+r8LC0YDBG0OpzugomNi+OIuHnjGvwrp6CEGYRrwu3rlLTDie10JB7ZZUqN4pl/S/VE7Ss= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699629182; c=relaxed/simple; bh=flhCm9MSqzvLfABJBzwd312Koj45heDM56rOwcvHx98=; h=DKIM-Signature:From:Date:To:Subject:Message-ID:MIME-Version; b=pL/JLnWETfCKthhEAltFc1PLrdC0zqga9Emh+BDNQYn1uOqVxM8yfvfHK2hit1B+bI/J+OHpvujOZgMPzSx+aiPzgzIH5JcMZLGxDq2pkbIcFLQ0tmQR0q1Vj+dYg4/1dmp2MMhryJKVlTP6PJjhxwzkKyYfYWoORjmz7J12KFU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699629180; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5vqiNbqypjyfjv7C3apgx9hdZ37N4P2StpnxXJsVxaw=; b=ViEhqkclsyyUWnf378JjRFRuXgNHnuAGQ6L+NiIBuIog1/DNM/G5RsT2yLRwjiI+3XUJRS FXP52orv4teVdab1VRlt0yOExkbe4atvLp7igQh/QzrBenCwZuVsQOZkWVBeTu4f4fh70C XNcF4uis3DT81sukk8H+s1muLfyRPrE= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-625-F6kBogtMOl6v41IpaWqMsQ-1; Fri, 10 Nov 2023 10:12:59 -0500 X-MC-Unique: F6kBogtMOl6v41IpaWqMsQ-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-66d20c7dad2so22575526d6.2 for ; Fri, 10 Nov 2023 07:12:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699629178; x=1700233978; h=mime-version:references:message-id:in-reply-to:subject:cc:to:date :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5vqiNbqypjyfjv7C3apgx9hdZ37N4P2StpnxXJsVxaw=; b=aRcilI2sscnNtnXr0TBr0buvwloDNSTS6jSay5ITRoq+fTHy2IOzowcVZY/rPlQykz 1LtQMxVu/tfJ44ktgRUkVNSbU7qjXPqIBgY/xvF+3ZIG5130bXjuSlGyS+0zRSTu50+1 oAKXfHYuTBNbGA7nG0f45RlBS4IyiA7Nxh8feEUMZA1d6H27/XjJ0D7bPbccRUfX+aH4 6lFcGD2M1nnCZP5ffXmGkP0hlunAR4M86cGbt0+gLOtmkgEWGPBcJ+QyCyKfP9dEvPTX ULDfl8GCq8LFJKGk7yWKny/ap0ELWC9NYFmNpkM5JAa5nTwKj+4D2iW7m350nc1cbl0P hqQw== X-Gm-Message-State: AOJu0Yx5B2EZbShynroOyzr7aoMlLbL/Jlm+oY1F6cQTbzpQQLDjoVGI 6+GQI9jgV9i5gsmPeSzxGaU6YjZ6idoj5mb0418LFm4hBQdBQ1IpWNeOEGtLsOfWt39wHdgm16Y p1bStJKuZ3csGrBaJ0g== X-Received: by 2002:a05:6214:5012:b0:671:4d4b:868f with SMTP id jo18-20020a056214501200b006714d4b868fmr9444464qvb.65.1699629178492; Fri, 10 Nov 2023 07:12:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IHX+7rNHdjW9/XYUdrgxEPZIxhugehMMIWJJiQ3AdS+7PZ4deojroljerbMVbwWSlS3hZKhTg== X-Received: by 2002:a05:6214:5012:b0:671:4d4b:868f with SMTP id jo18-20020a056214501200b006714d4b868fmr9444447qvb.65.1699629178220; Fri, 10 Nov 2023 07:12:58 -0800 (PST) Received: from [192.168.1.130] (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id z10-20020a0cfeca000000b006585069e894sm2915062qvs.109.2023.11.10.07.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Nov 2023 07:12:57 -0800 (PST) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Fri, 10 Nov 2023 10:12:57 -0500 (EST) To: Jason Merrill cc: Patrick Palka , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] c++: non-dependent .* folding [PR112427] In-Reply-To: <375a6726-8998-4b6b-830f-32852ef116b1@redhat.com> Message-ID: References: <20231108215904.2779753-1-ppalka@redhat.com> <375a6726-8998-4b6b-830f-32852ef116b1@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-13.8 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 Thu, 9 Nov 2023, Jason Merrill wrote: > 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. Hmm, that seems harmless at first glance, but I noticed build_min_non_dep (called from build_x_binary_op in this case) is careful to propagate TREE_SIDE_EFFECTS of the given tree, and so eliding POINTER_PLUS_EXPR here could potentially mean that the tree we ultimately return from build_x_binary_op when in a template context has TREE_SIDE_EFFECTS not set when it used to. Shall we still elide the POINTER_PLUS_EXPR in a template context despite this? (The TREE_SIDE_EFFECTS propagation in build_min_non_dep was added in r71108 to avoid bogus ahead of time -Wunused-value warnings. But then r105273 later made us stop issuing -Wunused-value warnings ahead of time altogether. So perhaps we don't need to maintain the TREE_SIDE_EFFECTS flag on templated trees at all anymore?) > > Jason > >