public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug middle-end/110091] New: bogus -Wdangling-pointer on non-pointer values @ 2023-06-02 12:00 patrickdepinguin at gmail dot com 2023-06-02 22:05 ` [Bug tree-optimization/110091] " pinskia at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: patrickdepinguin at gmail dot com @ 2023-06-02 12:00 UTC (permalink / raw) To: gcc-bugs 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). ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/110091] bogus -Wdangling-pointer on non-pointer values 2023-06-02 12:00 [Bug middle-end/110091] New: bogus -Wdangling-pointer on non-pointer values patrickdepinguin at gmail dot com @ 2023-06-02 22:05 ` 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 ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-06-02 22:05 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110091 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2023-06-02 Keywords| |compile-time-hog Component|middle-end |tree-optimization Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Function split decides to split out the call to anotherfunc (and the clobber of the entry struct) from bar and then the diagnostic gets confused from that. This is a bad split in the first place. ``` Splitting function at: Split point at BB 6 header time: 19.904000 header size: 12 split time: 7.260000 split size: 2 bbs: 6 SSA names to pass: ... void bar.part.0 () { struct tEntry entry; <bb 4> [local count: 1073741824]: <bb 2> [local count: 1073741824]: anotherfunc (5); entry ={v} {CLOBBER(eol)}; <bb 3> [local count: 1073741824]: return; } ``` ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/110091] [12/13/14 Regression] bogus -Wdangling-pointer on non-pointer values 2023-06-02 12:00 [Bug middle-end/110091] New: bogus -Wdangling-pointer on non-pointer values patrickdepinguin at gmail dot com 2023-06-02 22:05 ` [Bug tree-optimization/110091] " pinskia at gcc dot gnu.org @ 2023-06-02 22:07 ` 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 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-06-02 22:07 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110091 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|bogus -Wdangling-pointer on |[12/13/14 Regression] bogus |non-pointer values |-Wdangling-pointer on | |non-pointer values Target Milestone|--- |12.4 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- The split started happening in GCC 12 too. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/110091] [12/13/14 Regression] bogus -Wdangling-pointer on non-pointer values 2023-06-02 12:00 [Bug middle-end/110091] New: bogus -Wdangling-pointer on non-pointer values patrickdepinguin at gmail dot com 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 3 siblings, 0 replies; 5+ messages in thread From: jamborm at gcc dot gnu.org @ 2024-01-10 15:40 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110091 Martin Jambor <jamborm at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jamborm at gcc dot gnu.org Keywords|needs-bisection | --- Comment #3 from Martin Jambor <jamborm at gcc dot gnu.org> --- The warning started appearing from its very introduction to gcc in r12-6606-g9d6a0f388eb048 (Martin Sebor: Add -Wdangling-pointer [PR63272]). ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/110091] [12/13/14 Regression] bogus -Wdangling-pointer on non-pointer values 2023-06-02 12:00 [Bug middle-end/110091] New: bogus -Wdangling-pointer on non-pointer values patrickdepinguin at gmail dot com ` (2 preceding siblings ...) 2024-01-10 15:40 ` jamborm at gcc dot gnu.org @ 2024-01-12 14:13 ` rguenth at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: rguenth at gcc dot gnu.org @ 2024-01-12 14:13 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110091 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P3 |P2 CC| |hubicka at gcc dot gnu.org, | |rguenth at gcc dot gnu.org --- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- Honza? Why do we consider to split before anotherfunc(5)? It's an odd place since we'll always arrive there from the point we insert the call? The only other sensible point would have been before if (out), thus BB4? ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-12 14:13 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-06-02 12:00 [Bug middle-end/110091] New: bogus -Wdangling-pointer on non-pointer values patrickdepinguin at gmail dot com 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
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).