public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "eggert at cs dot ucla.edu" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-106427-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106427 Bug ID: 106427 Summary: -Wuse-after-free=3 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=53341&action=edit Compile with '-O2 -S -Wuse-after-free=3' 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=3 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 = p == end;' and thinks that accessing 'stop' later implies accessing a freed pointer. u.i: In function ‘coalesce_segment’: u.i:6486:18: warning: pointer ‘p’ used after ‘free’ [-Wuse-after-free] 6486 | for (stop = 0; !stop;) | ^~~~~ In function ‘wsnode_free’, inlined from ‘coalesce_segment’ at u.i:6499:4: u.i:6316:3: note: call to ‘free’ here 6316 | free (p); | ^~~~~~~~
next reply other threads:[~2022-07-24 19:52 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-07-24 19:52 eggert at cs dot ucla.edu [this message] 2022-08-27 7:17 ` [Bug middle-end/106427] " simon at josefsson dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-106427-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).