public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/63446] dangling reference results in confusing diagnostic from -Wuninitialized Date: Fri, 16 Apr 2021 17:17:08 +0000 [thread overview] Message-ID: <bug-63446-4-8yDhYHU9OH@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-63446-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63446 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2014-10-03 00:00:00 |2021-4-16 Known to fail| |10.2.0, 11.0, 4.6.4, 4.9.4, | |5.5.0, 6.4.0, 7.2.0, 8.3.0, | |9.1.0 CC| |msebor at gcc dot gnu.org Severity|normal |enhancement Blocks| |49974 --- Comment #9 from Martin Sebor <msebor at gcc dot gnu.org> --- GCC 11 improves the message by including a note that mentions the uninitialized variable. In this case it doesn't completely solve the problem because the variable it points to is initialized but it should help. pr63446.C: In function ‘int func()’: pr63446.C:15:14: warning: ‘x’ is used uninitialized [-Wuninitialized] 15 | return f.ref; | ^~~ pr63446.C:8:9: note: ‘x’ was declared here 8 | int x = 42; | ^ But the underlying bug here is returning a reference to a local variable, so the warning to improve is -Wreturn-local-addr. That will diagnose the return statement in make_foo(). Bug 49974 tracks that enhancement. With that, the additional -Wuninitialized issued in func() would just help clarify the consequences of the bug but not otherwise be essential. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49974 [Bug 49974] missing -Wreturn-local-addr for indirectly returning reference to local/temporary
prev parent reply other threads:[~2021-04-16 17:17 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-63446-4@http.gcc.gnu.org/bugzilla/> 2014-10-03 0:16 ` manu at gcc dot gnu.org 2014-10-03 7:10 ` glisse at gcc dot gnu.org 2014-10-03 7:18 ` glisse at gcc dot gnu.org 2014-10-03 11:37 ` manu at gcc dot gnu.org 2014-10-03 12:13 ` glisse at gcc dot gnu.org 2014-10-03 13:51 ` glisse at gcc dot gnu.org 2014-10-03 14:57 ` manu at gcc dot gnu.org 2021-04-16 17:17 ` msebor at gcc dot gnu.org [this message]
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-63446-4-8yDhYHU9OH@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).