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 F355A3858C31 for ; Fri, 17 Feb 2023 13:44:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F355A3858C31 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=1676641493; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xsZhB4gxlWQ7B6yMivelNXJgKPLsBPQk/GQVCeqyVQI=; b=QLcJSZ1KrnwJm7ssxjUfCEvi2upa1emYD/HED0nfHS/hKRCVZVzUg+oeFKQ5aPjZc9w+z/ HZ9TnoplyXT7Ia0tuoC3AyPK+a0CgPu+UWGtFgcwdnlLgrDgPZOeBn1crVhpx6wGwuDhIm AjHDgegbYgNMUpAbkD90rJYR+xjrYLM= 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_128_GCM_SHA256) id us-mta-663-o3r0vnJSNYiPjGm63yvMwQ-1; Fri, 17 Feb 2023 08:44:52 -0500 X-MC-Unique: o3r0vnJSNYiPjGm63yvMwQ-1 Received: by mail-qt1-f198.google.com with SMTP id i11-20020ac85e4b000000b003bcf4239f33so555923qtx.7 for ; Fri, 17 Feb 2023 05:44:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=xsZhB4gxlWQ7B6yMivelNXJgKPLsBPQk/GQVCeqyVQI=; b=6pmxliZEWoy0Gr1OkXf8L/hB9/vaZnlHBfwO2bwLsz+dweY6Sxy51twrGpDSV55Kqx e6ZjFe3kcu0Gsz3fyY3Z5PpNSLemNCk279AYy9AR2lnOtqDM9e4ppjN1P5veap7pdror teGiDtoVuDolXZemyyxk69iF4OvRMpBrefSefT1WPA7dYzamBXXwmy1HDlIEkEyFeTSk rSz7kTF7Re5XaC5F7pTMZz9Aeq437pOY2e8rqvkj3SSlEoebYBD2rtyl0k8CrCh/jg0u O/BkSekMSJKplDAjvEZzDCUOli2jv+IMUDPCCQuF3hoPoF6Y3iA/4dw6J+1/6SVCWymy GmMQ== X-Gm-Message-State: AO0yUKU2lXrQlvbg7H1qF3rCtb5R7oBDQoGp4vlWvbZ7ys036k2quFvv BndhY4Saj0suLIsRnzQ/Wl+4M+15zBKXZSZZCKe2weWyu/tZQ0Shz/8Lv7xOufq8Jc1q523RGH+ fc31dRuM= X-Received: by 2002:a05:6214:2408:b0:56f:154:250a with SMTP id fv8-20020a056214240800b0056f0154250amr10189663qvb.11.1676641491888; Fri, 17 Feb 2023 05:44:51 -0800 (PST) X-Google-Smtp-Source: AK7set/9sNem8zdXSgI5SWg1xgmYDfvllk13spS6PKkwvTuguVYr3uAKS7PxE9OLE5iDcIe2nCVc/g== X-Received: by 2002:a05:6214:2408:b0:56f:154:250a with SMTP id fv8-20020a056214240800b0056f0154250amr10189649qvb.11.1676641491689; Fri, 17 Feb 2023 05:44:51 -0800 (PST) Received: from t14s.localdomain (c-73-69-212-193.hsd1.ma.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id r207-20020a3744d8000000b00706bc44fda8sm3241904qka.79.2023.02.17.05.44.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Feb 2023 05:44:51 -0800 (PST) Message-ID: <500fdb4e5352e5140fd57ec3cb94090b15fc2cfe.camel@redhat.com> Subject: Re: Missed warning (-Wuse-after-free) From: David Malcolm To: Siddhesh Poyarekar , Alejandro Colomar , GCC Cc: Iker Pedrosa Date: Fri, 17 Feb 2023 08:44:49 -0500 In-Reply-To: References: <8ed6d28c-69dc-fed8-5ab5-99f685f06fac@gmail.com> <38e7e994a81d2a18666404dbaeb556f3508a6bd6.camel@redhat.com> User-Agent: Evolution 3.44.4 (3.44.4-1.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.8 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 Thu, 2023-02-16 at 22:48 -0500, Siddhesh Poyarekar wrote: > On 2023-02-16 10:15, David Malcolm via Gcc wrote: > > I'm not convinced that it's useful to the end-user to warn about > > the > > "use of q itself" case. >=20 > FWIW, -Wuse-after-free=3D3 already should do this: >=20 > At level 3, the warning also diagnoses uses of indeterminate pointers > in=20 > equality expressions.=C2=A0 All uses of indeterminate pointers are > undefined=20 > but equality tests sometimes appear after > calls to "realloc" as an attempt to determine whether the call > resulted=20 > in relocating the object to a different address.=C2=A0 They are diagnosed > at=20 > a separate level to aid legacy code gradually > transition to safe alternatives. This is possibly a silly question, but what *are* these safe alternatives? [1] How does one test to see if an object has been reallocated? Dave [1] Would suggesting "rust" here be too snarky? :-P > =C2=A0 For example, the equality test in the=20 > function below is diagnosed at this level: >=20 > Jakub and I had discussed this in the context of _FORTIFY_SOURCE=3D3=20 > (which is anal about this and can break things) and we got pr#105217, > but that is also a best-effort thing, not really a guarantee. >=20 > IMO the analyzer should go that extra mile and warn for the use of q=20 > itself and maybe deprecate -Wuse-after-free=3D3 in its favour. >=20 > Sid >=20