public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug middle-end/104958] New: missing -Wdangling-pointer leaking local address through struct member @ 2022-03-16 15:56 msebor at gcc dot gnu.org 2022-03-16 15:57 ` [Bug middle-end/104958] " msebor at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: msebor at gcc dot gnu.org @ 2022-03-16 15:56 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104958 Bug ID: 104958 Summary: missing -Wdangling-pointer leaking local address through struct member Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- As discussed in https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590230.html both functions in the following test case leak the address of the local variable to their caller and should trigger a -Wdangling pointer but only one of them does. The patch submitted to implement this missing functionality was deferred until GCC 13: https://gcc.gnu.org/pipermail/gcc-patches/attachments/20220210/2641dce0/attachment-0003.bin $ cat x.c && gcc -S -Wall x.c struct S { void *p; }; void f (struct S *p) { int j; p->p = &j; // -Wdangling-pointer } struct S g (void) { int i; struct S s = { &i }; // missing -Wdangling-pointer return s; } x.c: In function ‘f’: x.c:6:8: warning: storing the address of local variable ‘j’ in ‘*p.p’ [-Wdangling-pointer=] 6 | p->p = &j; // -Wdangling-pointer | ~~~~~^~~~ x.c:5:7: note: ‘j’ declared here 5 | int j; | ^ x.c:5:7: note: ‘p’ declared here ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/104958] missing -Wdangling-pointer leaking local address through struct member 2022-03-16 15:56 [Bug middle-end/104958] New: missing -Wdangling-pointer leaking local address through struct member msebor at gcc dot gnu.org @ 2022-03-16 15:57 ` msebor at gcc dot gnu.org 2022-12-11 1:55 ` pinskia at gcc dot gnu.org 2022-12-11 1:56 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: msebor at gcc dot gnu.org @ 2022-03-16 15:57 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104958 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2022-03-16 Keywords| |diagnostic Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Blocks| |104077 Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104077 [Bug 104077] bogus/missing -Wdangling-pointer ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/104958] missing -Wdangling-pointer leaking local address through struct member 2022-03-16 15:56 [Bug middle-end/104958] New: missing -Wdangling-pointer leaking local address through struct member msebor at gcc dot gnu.org 2022-03-16 15:57 ` [Bug middle-end/104958] " msebor at gcc dot gnu.org @ 2022-12-11 1:55 ` pinskia at gcc dot gnu.org 2022-12-11 1:56 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-12-11 1:55 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104958 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ozixtheorange at gmail dot com --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- *** Bug 106508 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/104958] missing -Wdangling-pointer leaking local address through struct member 2022-03-16 15:56 [Bug middle-end/104958] New: missing -Wdangling-pointer leaking local address through struct member msebor at gcc dot gnu.org 2022-03-16 15:57 ` [Bug middle-end/104958] " msebor at gcc dot gnu.org 2022-12-11 1:55 ` pinskia at gcc dot gnu.org @ 2022-12-11 1:56 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-12-11 1:56 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104958 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- A C++ example with lamdbas which shows the same issue here (the IR is basically the same): int outer; auto fn1(int val = 0){ return [&]{ outer = val; // invalid }; } ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-12-11 1:56 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-03-16 15:56 [Bug middle-end/104958] New: missing -Wdangling-pointer leaking local address through struct member msebor at gcc dot gnu.org 2022-03-16 15:57 ` [Bug middle-end/104958] " msebor at gcc dot gnu.org 2022-12-11 1:55 ` pinskia at gcc dot gnu.org 2022-12-11 1:56 ` pinskia 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).