From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 84782393A437; Wed, 12 Jan 2022 12:54:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84782393A437 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103989] [12 regression] std::optional and bogus -Wmaybe-unitialized at -Og since r12-1992-g6feb628a706e86eb Date: Wed, 12 Jan 2022 12:54:37 +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: 12.0 X-Bugzilla-Keywords: 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: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: target_milestone 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: Wed, 12 Jan 2022 12:54:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103989 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |12.0 --- Comment #2 from Richard Biener --- The IL has [local count: 1073741824]: D.35417 =3D D.35181; [/home/rguenther/install/gcc-12/usr/local/include/c++/12.0.0/optional:737= :17] D.34833 =3D{v} {CLOBBER}; [/home/rguenther/install/gcc-12/usr/local/include/c++/12.0.0/optional:237= :14] MEM[(union _Storage *)[t.C:26:20] &D.34833] =3D{v} {CLOBBER}; [/home/rguenther/install/gcc-12/usr/local/include/c++/12.0.0/optional:118= :7] [/home/rguenther/install/gcc-12/usr/local/include/c++/12.0.0/optional:118:7] MEM[(struct _Optional_payload_base *)[t.C:26:20] &D.34833]._M_engaged =3D 0; [t.C:26:20] D.35417 =3D{v} {CLOBBER}; I suspect we warn on the use of D.35181 which is indeed not initialized (of std::nullopt_t type). The copied to D.35417 is dead but at -Og we fail to elide the store. I see there's no DSE performed for -Og possibly on purpose to not degrade debug info more. But that makes -Wuninitialized susceptible for these kind of issues. Note at -O1 the same IL is in the program, it's just elided before we get the chance to warn on it. The uninit use there is even visible before inlining but we don't seem to diagnose by value passing of uninitialized aggregates: int main () { struct B b; struct nullopt_t D.35181; const struct optional D.34833; int _8; : [t.C:26:20] std::optional::optional ([t.C:26:20] &D.34833, D.35181); here D.35181 is passed to the CTOR (where it might be eventually not used so not warning at the call is eventually OK). The copy itself is emitted by the inliner, so it's spurious to warn there and the inliner could either try harder to not emit it or alternatively mark the copy as to be not warned about.=