From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 89004388E80E; Mon, 9 May 2022 13:21:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 89004388E80E From: "rguenth at gcc dot 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:21:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW 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: Message-ID: In-Reply-To: References: 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: Mon, 09 May 2022 13:21:59 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105534 --- Comment #2 from Richard Biener --- Note there's _2 =3D value_1(D) * x_2; where _2 might be effectively uninitialized iff x_2 is not zero. When x_2 is zero then _2 has a well-defined value. So to start thinking about this I'd do a RPO walk recording a lattice of { UNDEF, MAY_UNDEF, DEF } where the above would be "MAY_UNDEF". PHIs would then simply merge. That would be enough to better distinguish may from must in case the must diagnostic is OK for the two different variables being returned. Otherwise that needs to be taken into account as well, maybe by tracking which variables a value is from. Consider void test (int x) { int value1, value2; return (value1 * x) + value2; } where we maybe use value1 uninitialized and definitely value2. Note this all leaves open which point to diagnose - the expression closest to the (possibly conditional and possible multiple) computations with value1 and value2 or the expression where the first (or last?) unconditional use appears in?=