From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 02A473858C2C; Fri, 26 May 2023 14:31:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 02A473858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685111508; bh=sRADl+FRltnw7WMpw04sE5gyFwWS2Ss6oIcennSFCyg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=aGgw0OZOfTSwJ1zCX50QfJHHzQDD4gFkYZRZyYXom2r1u0ZTynuLb3f7/DyXOa306 MACbBiLgBDxMpq4Sz6/bDjDk12/BkvcUoTK7I4HHuaG34nKgSP5KHVBC/56AqhLan2 Z2v1kIsQK2M7SXmNBls3Abr4IWejFAyk3q4xpQHw= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/109990] [12/13/14 Regression] Bogus -Wuse-after-free warning after realloc Date: Fri, 26 May 2023 14:31:47 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109990 --- Comment #3 from Andrew Pinski --- (In reply to Andrew Pinski from comment #1) > ``` >=20 > char *new_pool =3D (char *) realloc (string_space, new_= size); > if (new_pool =3D=3D ((void *)0)) > goto out; > if (__builtin_expect (string_space !=3D new_pool, 0)) > { > size_t i; > for (i =3D 0; i < nmap; i++) > { > map[i].alias +=3D new_pool - string_space; > map[i].value +=3D new_pool - string_space; > } > } > string_space =3D new_pool; > ``` >=20 > Hmmm Also I think `new_pool - string_space` is undefined really. That is subtracting two unrelated arrays is undefined. You can only compare equalit= y on them.=