From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 214173852C4A; Wed, 23 Nov 2022 16:25:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 214173852C4A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669220711; bh=mm0xUlvEhKnX9mAiy7jsy0oqCfvmeXgCfO34yWEGUH4=; h=From:To:Subject:Date:From; b=E4fC9I9y6Aius3OUwuvLWPksnWqJHrMOu/dBUeECPlyS30q0V+JZGufU6y8hzth1Q 4Clx5ZHUE5Fsi2Ua2eyxxUcEWyoP0C3PX3XLGxpaCzLItUAGkmxIKmourzBjde9M+B LXMCMzWPjnIvRXuuAxMRetZVX6gPuu0Y943v/Vdw= From: "vincent-gcc at vinc17 dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107838] New: spurious "may be used uninitialized" warning on variable initialized at the first iteration of a loop Date: Wed, 23 Nov 2022 16:25:10 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vincent-gcc at vinc17 dot net 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 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107838 Bug ID: 107838 Summary: spurious "may be used uninitialized" warning on variable initialized at the first iteration of a loop Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vincent-gcc at vinc17 dot net Target Milestone: --- Consider int f(void); void g(int *t) { int i, v; for (i =3D 0; i < 9; i++) { if (i =3D=3D 0) v =3D f(); if (v + t[i]) f(); } } $ gcc-test -O -Wmaybe-uninitialized -c tst3.c tst3.c: In function =E2=80=98g=E2=80=99: tst3.c:9:13: warning: =E2=80=98v=E2=80=99 may be used uninitialized [-Wmayb= e-uninitialized] 9 | if (v + t[i]) | ~~^~~~~~ tst3.c:4:10: note: =E2=80=98v=E2=80=99 was declared here 4 | int i, v; | ^ The variable v is initialized at the first iteration (i =3D=3D 0). Therefor= e the warning is incorrect. This occurs with GCC 4.8, 6.5.0, 8.4.0, 9.5.0, 12.2.0, and 13.0.0 20220906 (experimental) from the master branch. But there are no warnings with GCC 4= .9, 5.5.0, 10.4.0 and 11.3.0. Note to myself (to check once this bug is fixed): this testcase is derived = from tmd/binary32/hrcases.c (warning on variable b).=