From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id F418B385772C for ; Sat, 15 Apr 2023 01:22:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F418B385772C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-24736992dd3so210683a91.1 for ; Fri, 14 Apr 2023 18:22:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681521730; x=1684113730; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=5hM717wtTv32iImGKv5f4lBU4PJahDcLPXIe94eOWyI=; b=fnM/dBNOEkJyEFoIq0O6GdluvQBexG1ODqtNmIh6Tznm7J5maEZDxlrY8SETG/6ym+ ZhX6RWEbvV2P0U/BjiRKWu64krJY/mef3lFqOdSzR3lqK2bl6OVi8s9SsxO8agkJFjGG oubCgvtAAuUWim+PdiJXRkad3rNzD04Gjoup7lt1R78m3JlEZNJfJlB13tUoXlorfPZ/ VhHjCOQUXQWnIePrP3UIazR0tFZKdqyCaaxS4Ex+IYcTMa9f5VvdftZk1aPMc2RZ/mA0 gsyoegRTfcY+R3SYWPlpBfNxnOKiYomU830IssncRYpGRxVKiGAhhRWndZHovvihV68a 5ZEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681521730; x=1684113730; 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=5hM717wtTv32iImGKv5f4lBU4PJahDcLPXIe94eOWyI=; b=Irc818fXBBkxtTB/34NDkKvMYGSslxsKjXz8L0C2C5LpsdYRL/fpBcxuivYjh6bcy9 LFVEqDdLi3QgQ4DZ9QSGlFYEkSfeUYEAijzSNxvGJGw4UBGrGq8uERzzL1zjcxRZXtbf qxB8ME5dEk9qwOB3W/jlqj0+awhACrD9SmARU7Os+cOEJLbQQqvblBmsrVGR849MpON3 /eP20Sjf+IuSMThakayAGGrSzjtUHlmVx+v943xYK5e/byOQexAYpUWOD3QB5D1aVoL2 lbgNqRJE97XZoiuJEj/GUsq8sxW9ct0ytUZWCP6/lGx4djlCFZZp7SR3FGGSHPFp1ag6 np/A== X-Gm-Message-State: AAQBX9fJijVxzTGW1DIUA8ySX4oRXOFJsMamBkhbwmCb88lT8R91GADG TWIjSU5/zNbxIWPmENK+HdA= X-Google-Smtp-Source: AKy350ZloHPKofsxz5iP50QgV9xK9Ae7U8QagWZjwdpEF3Ly0Noiz/mMonZ35GrCp8P588N1+1uRag== X-Received: by 2002:a05:6a00:a05:b0:5e0:a86:a76f with SMTP id p5-20020a056a000a0500b005e00a86a76fmr10777961pfh.0.1681521729494; Fri, 14 Apr 2023 18:22:09 -0700 (PDT) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id 16-20020aa79210000000b006328ee1e56csm3585025pfo.2.2023.04.14.18.22.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Apr 2023 18:22:08 -0700 (PDT) Message-ID: <032ca48b-6e8c-f469-ab28-37933ea0ecf5@gmail.com> Date: Fri, 14 Apr 2023 19:22:07 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH RFA] -Wdangling-pointer: fix MEM_REF handling [PR109514] Content-Language: en-US To: Jason Merrill , gcc-patches@gcc.gnu.org References: <20230414234224.2870389-1-jason@redhat.com> From: Jeff Law In-Reply-To: <20230414234224.2870389-1-jason@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 4/14/23 17:42, Jason Merrill via Gcc-patches wrote: > Tested x86_64-pc-linux-gnu, ok for trunk? > > -- 8< -- > > Here we hit the MEM_REF case, with its arg an ADDR_EXPR, but had no handling > for that and wrongly assumed it would be a reference to a local variable. > This patch overhauls the logic for deciding whether the target is something > to warn about so that we only warn if we specifically recognize the target > as non-local. None of the existing tests regress as a result. > > PR c++/109514 > > gcc/ChangeLog: > > * gimple-ssa-warn-access.cc (pass_waccess::check_dangling_stores): > Overhaul lhs_ref.ref analysis. > > gcc/testsuite/ChangeLog: > > * g++.dg/warn/Wdangling-pointer-6.C: New test. One might ask if we have a (MEM_REF (ADDR_REF ...)) why we didn't simplify that by removing the MEM_REF and ADDR_REF wrappers. But on the assumption there's a good reason to have such nodes, OK for the trunk. jeff