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 6D3893858D37 for ; Wed, 2 Feb 2022 20:36:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D3893858D37 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-1-JLeiN9GXPbWzrlBTMAb_kw-1; Wed, 02 Feb 2022 15:36:02 -0500 X-MC-Unique: JLeiN9GXPbWzrlBTMAb_kw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B2A2651082; Wed, 2 Feb 2022 20:36:01 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 428F360C05; Wed, 2 Feb 2022 20:36:01 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 212KZw482043405 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 2 Feb 2022 21:35:58 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 212KZuPY2043404; Wed, 2 Feb 2022 21:35:56 +0100 Date: Wed, 2 Feb 2022 21:35:56 +0100 From: Jakub Jelinek To: Jeff Law Cc: Richard Biener , gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Re: [PATCH] Add CLOBBER_MARKS_EOL to mark storage end-of-life clobbers Message-ID: <20220202203556.GE2646553@tucnak> Reply-To: Jakub Jelinek References: <20220202144248.8F84513E6F@imap2.suse-dmz.suse.de> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Feb 2022 20:36:12 -0000 On Wed, Feb 02, 2022 at 01:23:44PM -0700, Jeff Law via Gcc-patches wrote: > Note that I think something similar may be needed to mark EOL for the > pointer passed to realloc to fix a related set of false positives for code > like this > >   bool something = p != q; >   whatever = realloc (p, newsize) >   if (something) > > We forward propagate the p != q test generating something like this; > >   whatever - realloc (p, newsize); >   if (p != q) IMNSHO we shouldn't warn for pointer passed to realloc being used in equality comparisons at all, it is just unnecessarily pedantic, it works just fine and a lot of programs use it to find out if the memory was actually reallocated or was just extended or shrunk in place; in the former case they often need some extra work, such as adjust something in the memory block. Yes, one can probably do uintptr_t pint = (uintptr_t) p; whatever = realloc (p, newsize); if ((uintptr_t) whatever != pint) but I think most people don't bother. Jakub