From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3D1BF385840A; Sun, 24 Jul 2022 19:52:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D1BF385840A From: "eggert at cs dot ucla.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/106427] New: -Wuse-after-free=3 false alarm about int (not pointer) variable Date: Sun, 24 Jul 2022 19:52:32 +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: 12.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: eggert at cs dot ucla.edu 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jul 2022 19:52:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106427 Bug ID: 106427 Summary: -Wuse-after-free=3D3 false alarm about int (not pointer) variable Product: gcc Version: 12.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: eggert at cs dot ucla.edu Target Milestone: --- Created attachment 53341 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D53341&action=3Dedit Compile with '-O2 -S -Wuse-after-free=3D3' to demonstrate the bug I ran into this problem when building GNU Tar. Compile the attached program= u.i with "gcc -O2 -S -Wuse-after-free=3D3 u.i", using GCC 12.1.1 20220507 (Red = Hat 12.1.1-1) on x86-64. The output (shown below) is a false alarm, because the variable 'stop' is of type 'int', and is not a pointer. Apparently GCC is confused by the assignment statement 'stop =3D p =3D=3D end;' and thinks th= at accessing 'stop' later implies accessing a freed pointer. u.i: In function =E2=80=98coalesce_segment=E2=80=99: u.i:6486:18: warning: pointer =E2=80=98p=E2=80=99 used after =E2=80= =98free=E2=80=99 [-Wuse-after-free] 6486 | for (stop =3D 0; !stop;) | ^~~~~ In function =E2=80=98wsnode_free=E2=80=99, inlined from =E2=80=98coalesce_segment=E2=80=99 at u.i:6499:4: u.i:6316:3: note: call to =E2=80=98free=E2=80=99 here 6316 | free (p); | ^~~~~~~~=