From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 756993858015; Tue, 3 Aug 2021 23:50:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 756993858015 From: "eggert at cs dot ucla.edu" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: eggert at cs dot ucla.edu X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Aug 2021 23:50:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101770 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=3D51256&action=3Dedit False alarm with gcc -O2 -Wmaybe-uninitialized and only locals I found this problem while compiling sdiff.c from GNU diffutils. The attach= ed is is a simplified version. It appears to be distinct from GCC bug 101768 s= ince it involves only local variables. Compile it this way: gcc -O2 -Wmaybe-uninitialized -S w.i The output is: w.i: In function =E2=80=98edit=E2=80=99: w.i:50:18: warning: =E2=80=98cmd1=E2=80=99 may be used uninitialized in thi= s function [-Wmaybe-uninitialized] 50 | return !cmd1; | ^~~~~ This is a false alarm, because line 50 can be reached only if cmd0=3D=3D'e'= , and if cmd0=3D=3D'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, i= f 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.=