From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D40D03898523; Thu, 18 Feb 2021 21:05:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D40D03898523 From: "law at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/80635] [8/9/10/11 regression] std::optional and bogus -Wmaybe-uninitialized warning Date: Thu, 18 Feb 2021 21:05:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 8.2.0 X-Bugzilla-Keywords: diagnostic, patch X-Bugzilla-Severity: normal X-Bugzilla-Who: law at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: law at redhat dot com X-Bugzilla-Target-Milestone: 8.5 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: Thu, 18 Feb 2021 21:05:04 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D80635 --- Comment #57 from Jeffrey A. Law --- Below is a POC for improving the uninit analysis to handle this kind of cas= e.=20 It's not complete. In particular it does not ensure that the we have the s= ame result on the RHS and LHS of the V_C_E. Basically I'm just showing where/h= ow we could look through a V_C_E to determine that the use is properly guarded. + /* If FLAG_DEF is a V_C_E, then we can look through it. + The trick is to know when the V_C_E doesn't change the + value, which isn't validated yet. */ + if (is_gimple_assign (*flag_def) + && gimple_assign_rhs_code (*flag_def) =3D=3D VIEW_CONVERT_EXPR) + { + tree rhs =3D gimple_assign_rhs1 (*flag_def); + rhs =3D TREE_OPERAND (rhs, 0); + if (TREE_CODE (rhs) =3D=3D SSA_NAME) + { + if ((*flag_def =3D SSA_NAME_DEF_STMT (rhs)) =3D=3D NULL) + continue; + } + }=