public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "tony@develop-help.com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/108115] New: spurious pointer used after realloc warning Date: Thu, 15 Dec 2022 00:13:52 +0000 [thread overview] Message-ID: <bug-108115-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108115 Bug ID: 108115 Summary: spurious pointer used after realloc warning Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: tony@develop-help.com Target Milestone: --- Created attachment 54097 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54097&action=edit Code that demonstrates the warning gcc 12.0.1 produces a spurious warning when an access to an integer copy of a pointer is accessed within an unrelated runtime conditional. With the attachment: $ /opt/gcc-12.1.0/bin/gcc -c -std=c99 -O2 -Wall -Wextra gcc-20507-simple.c gcc-20507-simple.c: In function ‘my_realloc’: gcc-20507-simple.c:13:15: warning: pointer ‘p’ may be used after ‘realloc’ [-Wuse-after-free] 13 | uintptr_t u = (uintptr_t)p; | ^ gcc-20507-simple.c:15:18: note: call to ‘realloc’ here 15 | void *newp = realloc(p, newsz); | ^~~~~~~~~~~~~~~~~ $ /opt/gcc-12.1.0/bin/gcc -c -std=c99 -O2 -Wall -Wextra -DDEBUG=1 gcc-20507-simple.c (no diagnostics) Note that p is not used after the realloc() in either case.
next reply other threads:[~2022-12-15 0:13 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-12-15 0:13 tony@develop-help.com [this message] 2022-12-15 0:37 ` [Bug middle-end/108115] " pinskia at gcc dot gnu.org 2022-12-15 0:40 ` pinskia at gcc dot gnu.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-108115-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).