public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "patrickdepinguin at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/110091] New: bogus -Wdangling-pointer on non-pointer values Date: Fri, 02 Jun 2023 12:00:59 +0000 [thread overview] Message-ID: <bug-110091-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110091 Bug ID: 110091 Summary: bogus -Wdangling-pointer on non-pointer values Product: gcc Version: 12.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: patrickdepinguin at gmail dot com Target Milestone: --- Following reduced testcase gives a bogus -Wdangling-pointer: struct tEntry { int value; }; struct tOut { int outvalue; }; extern struct tOut *out; extern int otherfunc(struct tEntry *); extern void anotherfunc(int val); void bar() { struct tEntry entry = { 0 }; if (otherfunc(&entry) != 0) { return; } if (out) { out->outvalue = entry.value; } anotherfunc(5); } void foo() { bar(); } $ gcc -O2 -Wall -Werror /opt/test.c /opt/test.c: In function 'bar': /opt/test.c:26:30: error: dangling pointer to 'entry' may be used [-Werror=dangling-pointer=] 26 | out->outvalue = entry.value; | ~~~~~^~~~~~ /opt/test.c:17:19: note: 'entry' declared here 17 | struct tEntry entry = { 0 }; | ^~~~~ In function 'bar', inlined from 'foo' at /opt/test.c:34:5: /opt/test.c:26:30: error: dangling pointer to 'entry' may be used [-Werror=dangling-pointer=] 26 | out->outvalue = entry.value; | ~~~~~^~~~~~ /opt/test.c: In function 'foo': /opt/test.c:17:19: note: 'entry' declared here 17 | struct tEntry entry = { 0 }; | ^~~~~ cc1: all warnings being treated as errors entry is a local struct, initialized to 0, and passed as pointer to an external function. But the use being warned about is not using any pointer. Tested with 12.2.0 (Debian), 12.2.1 (Gentoo), 12.3.0 (official gcc docker image), 13.1.0 (official gcc docker image).
next reply other threads:[~2023-06-02 12:01 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-02 12:00 patrickdepinguin at gmail dot com [this message] 2023-06-02 22:05 ` [Bug tree-optimization/110091] " pinskia at gcc dot gnu.org 2023-06-02 22:07 ` [Bug tree-optimization/110091] [12/13/14 Regression] " pinskia at gcc dot gnu.org 2024-01-10 15:40 ` jamborm at gcc dot gnu.org 2024-01-12 14:13 ` rguenth 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-110091-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).