From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E79933858C60; Fri, 26 May 2023 13:58:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E79933858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685109520; bh=Cq7rHWWjfJhkI4jvd7eqiZe3gbctOMppWbi5niR0Pio=; h=From:To:Subject:Date:From; b=QO/0gJY9uw5Auwq+mv3L9TQ0bJhQUZ8tMIAd9nCOp6IQAM804L7v0qyqhPEKJD/Tl tr8sBxxdKbmWnRNSP0gK2Ow0eG55q3WK215/aZ/esSX/c1yASQ81w/8629Og1AXX30 1tilhlXnwVof0uGhRNG23pk62EcIVbtsiMlvyAo0= From: "bruno at clisp dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/109990] New: [12 Regression] Bogus -Wuse-after-free warning after realloc Date: Fri, 26 May 2023 13:58:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bruno at clisp dot 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: 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 Bug ID: 109990 Summary: [12 Regression] Bogus -Wuse-after-free warning after realloc Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: bruno at clisp dot org Target Milestone: --- Created attachment 55168 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D55168&action=3Dedit test case bar.c Compiling the attached file produces a warning that is not justified: $ gcc -Wall -O2 -S bar.c bar.c: In function =E2=80=98read_alias_file=E2=80=99: bar.c:122:52: warning: pointer may be used after =E2=80=98realloc=E2=80=99 = [-Wuse-after-free] 122 | map[i].alias +=3D new_pool - string_space; | ~~~~~~~~~^~~~~~~~~~~~~~ bar.c:114:45: note: call to =E2=80=98realloc=E2=80=99 here 114 | char *new_pool =3D (char *) realloc (string_space, new_size); |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The warning is not justified because only the pointer 'string_space' is used here; it is not being dereferenced. Seen with gcc 12.3.0 and 13.1.0.=