public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "eggert at cs dot ucla.edu" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101770] New: -Wmaybe-uninitialized false alarm with only locals in GNU diffutils Date: Tue, 03 Aug 2021 23:50:55 +0000 [thread overview] Message-ID: <bug-101770-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101770 Bug ID: 101770 Summary: -Wmaybe-uninitialized false alarm with only locals in GNU diffutils Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: eggert at cs dot ucla.edu Target Milestone: --- Created attachment 51256 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51256&action=edit False alarm with gcc -O2 -Wmaybe-uninitialized and only locals I found this problem while compiling sdiff.c from GNU diffutils. The attached is is a simplified version. It appears to be distinct from GCC bug 101768 since it involves only local variables. Compile it this way: gcc -O2 -Wmaybe-uninitialized -S w.i The output is: w.i: In function ‘edit’: w.i:50:18: warning: ‘cmd1’ may be used uninitialized in this function [-Wmaybe-uninitialized] 50 | return !cmd1; | ^~~~~ This is a false alarm, because line 50 can be reached only if cmd0=='e', and if cmd0=='e' then the previous switch statement (inside the while loop - line 27) guarantees that cmd1 has been initialized. I briefly tried to simplify the example further, but failed. For example, if I remove line 16 ("case '2':") the false alarm goes away. This is with gcc (GCC) 11.2.1 20210728 (Red Hat 11.2.1-1) on x86-64.
next reply other threads:[~2021-08-03 23:50 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-03 23:50 eggert at cs dot ucla.edu [this message] 2021-08-04 6:34 ` [Bug tree-optimization/101770] " rguenth at gcc dot gnu.org 2021-08-05 14:59 ` msebor at gcc dot gnu.org 2022-11-20 5:00 ` law at gcc dot gnu.org 2022-11-28 22:36 ` pinskia at gcc dot gnu.org 2023-05-19 21:16 ` eggert at cs dot ucla.edu 2023-05-19 21:44 ` eggert at cs dot ucla.edu
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-101770-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).