public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105534] -Wmaybe-uninitialized cases shouldn't suppress -Wuninitialized warnings Date: Mon, 09 May 2022 13:05:58 +0000 [thread overview] Message-ID: <bug-105534-4-9d7LudRsjB@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-105534-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105534 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Version|unknown |12.1.0 Last reconfirmed| |2022-05-09 Ever confirmed|0 |1 Keywords| |diagnostic Status|UNCONFIRMED |NEW --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. I think we are not considering that # count_1 = PHI <count_3(D)(5), count_4(3)> is actually the same variable plus that count_4 can be considered an uninitialized use even though it is (conditional) count_4 = count_3(D) + 1; instead what we are keying on is the uses of count_3(D) only, of which one is in the PHI and one in the add. Note that after emitting one diagnostic we're silencing the other because we mark 'count' as being already diagnosed. If you modify the testcase to int test(_Bool cond) { int count, count2; if (cond) return ++count; return count2; } you get t2.c: In function 'test': t2.c:3:22: warning: 'count' may be used uninitialized [-Wmaybe-uninitialized] 3 | if (cond) return ++count; | ^~~~~~~ t2.c:2:9: note: 'count' was declared here 2 | int count, count2; | ^~~~~ t2.c:4:12: warning: 'count2' may be used uninitialized [-Wmaybe-uninitialized] 4 | return count2; | ^~~~~~ t2.c:2:16: note: 'count2' was declared here 2 | int count, count2; | ^~~~~~ and the IL is very similar: <bb 3> [local count: 365072224]: count_5 = count_4(D) + 1; # _1 = PHI <count_5(3), count2_3(D)(5)> you would probably agree to the "may be used" kind used here in which case it's exactly noticing that the same variable is used on all paths into the PHI node. If you'd say this is also a case of an unconditional uninitialized use (it is!) then it might be even easier to implement this since we don't need to prove the variables returned are the same ones, just that they have uninitialized uses.
next prev parent reply other threads:[~2022-05-09 13:05 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-09 12:22 [Bug c++/105534] New: -Wmaybe-uninitialized " redbeard0531 at gmail dot com 2022-05-09 13:05 ` rguenth at gcc dot gnu.org [this message] 2022-05-09 13:21 ` [Bug c++/105534] -Wmaybe-uninitialized cases " rguenth at gcc dot gnu.org 2022-05-09 13:41 ` redbeard0531 at gmail dot com 2022-05-09 13:51 ` redbeard0531 at gmail dot com
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-105534-4-9d7LudRsjB@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).