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.133.124]) by sourceware.org (Postfix) with ESMTPS id 1D6313858D37 for ; Thu, 2 Mar 2023 21:24:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1D6313858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677792251; 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=Iwip2JuKNRC0M9HUvE+DlPjFkJqnBHu1fHyeGYWdCsM=; b=dV9gKEcJqm8d93r1Kp8CkKcPIPmgycHRhiHr1xzT2LBOl3tys5ZzP/I+y1U+6T0EAzv57S JN7rOzcQ/KDJy2HkHaD+ZrtW8+uMVNepBvhXgKwvJ4KYnOyv2nD1xOi89EWN7AaWuDEUr8 HPESYSBVzrNId8yNu20SQCsKBNA5YZg= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-622-_E5iP2fbPsK487x68eg9Qw-1; Thu, 02 Mar 2023 16:24:10 -0500 X-MC-Unique: _E5iP2fbPsK487x68eg9Qw-1 Received: by mail-qv1-f72.google.com with SMTP id lt7-20020a056214570700b0057290f3623eso359402qvb.3 for ; Thu, 02 Mar 2023 13:24:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Iwip2JuKNRC0M9HUvE+DlPjFkJqnBHu1fHyeGYWdCsM=; b=EvZkXu/iaucanIw6pWonnYC02+C98YonfePIb276/wc8cMM6Il7W7YLQzTjF+1q3Y7 LsgpSz84F/qe/IkATqrOZYM+M/PplXQwyNusbbY2h6F3p26dxaKWn9ITHTsxew4mmEIs PnNB9MUAP7FD6BAI6UNsFk7cLx4GgC6Sa8ITvQu02HlsUpzgZAPs4Y0lARCMrjt+n1WU R751CT9W7byFDIVq+k9pTD20ynCVg/QHDwoxk+at5aQQ1stC/3tGxqjMxl9pTrjGa52k wVs+YZoH5adDdFsKjPae8YF0Zs2LaX0b402vrgqxcw+ACUMTb5r9fwj2j/IFCHjOKX9z HHhQ== X-Gm-Message-State: AO0yUKVmxiin0iOdYL9UiwSSaFT2Xty1T9svMgQ8bRMR32aVm0XWxj0P TfLq/tuwWOZqviZOECxQXhRXihXQ3aRMevg0ghjdrC6krWNurKPRUpx4EO7quvZomU/ujtEtOfI xByfmbWMGDTGcmB2GmA== X-Received: by 2002:a05:622a:1448:b0:3b8:6215:789b with SMTP id v8-20020a05622a144800b003b86215789bmr19395018qtx.35.1677792250129; Thu, 02 Mar 2023 13:24:10 -0800 (PST) X-Google-Smtp-Source: AK7set94I4jehDr2efhAAu0Yw3jJCnvrZgZInlIlto13H0H282P5HbDgGWKP4OeqZ746KR73bTLfcA== X-Received: by 2002:a05:622a:1448:b0:3b8:6215:789b with SMTP id v8-20020a05622a144800b003b86215789bmr19395002qtx.35.1677792249856; Thu, 02 Mar 2023 13:24:09 -0800 (PST) Received: from redhat.com (2603-7000-9500-34a5-0000-0000-0000-1db4.res6.spectrum.com. [2603:7000:9500:34a5::1db4]) by smtp.gmail.com with ESMTPSA id g28-20020ac842dc000000b003bfb0ea8094sm418336qtm.83.2023.03.02.13.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 13:24:09 -0800 (PST) Date: Thu, 2 Mar 2023 16:24:07 -0500 From: Marek Polacek To: Jason Merrill Cc: GCC Patches Subject: Re: [PATCH v4] c++: -Wdangling-reference with reference wrapper [PR107532] Message-ID: References: <20230118175200.365397-1-polacek@redhat.com> <0024ebdb-ecf2-d841-0e73-7063e4dcb9fe@redhat.com> <61a408eb-d9a8-6c3b-4d7a-367fe0d3997e@redhat.com> <81d1c004-82c2-096f-d2f0-48e365dd954a@redhat.com> MIME-Version: 1.0 In-Reply-To: <81d1c004-82c2-096f-d2f0-48e365dd954a@redhat.com> User-Agent: Mutt/2.2.9 (2022-11-12) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP 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 Wed, Mar 01, 2023 at 04:53:23PM -0500, Jason Merrill wrote: > > @@ -13791,12 +13830,39 @@ std_pair_ref_ref_p (tree t) > > const int& y = (f(1), 42); // NULL_TREE > > const int& z = f(f(1)); // f(f(1)) > > - EXPR is the initializer. */ > > + EXPR is the initializer. If ARG_P is true, we're processing an argument > > + to a function; the point is to distinguish between, for example, > > + > > + Ref::inner (&TARGET_EXPR ) > > + > > + where we shouldn't warn, and > > + > > + Ref::inner (&TARGET_EXPR )>) > > + > > + where we should warn (Ref is a reference_like_class_p so we see through > > + it. */ > > static tree > > -do_warn_dangling_reference (tree expr) > > +do_warn_dangling_reference (tree expr, bool arg_p) > > { > > STRIP_NOPS (expr); > > + if (TREE_CODE (expr) == ADDR_EXPR) > > + expr = TREE_OPERAND (expr, 0); > > I think if we move this here, we also need to check that expr before > STRIP_NOPS had REFERENCE_TYPE. OK with that change. Sorry but I don't think I can do that. There can be CONVERT_EXPRs that need to be stripped, whether arg_p or !arg_p. For example, we can get (const int *) f ((const int &) &TARGET_EXPR >) for const int& r5 = (42, f(10)); Is the patch OK as-is then? Marek