From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1FD903857428; Mon, 10 Oct 2022 23:14:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FD903857428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665443650; bh=YLukiCHX/iufbCCweEIoRV+lmB7DB98RrrRUre1H7ts=; h=From:To:Subject:Date:From; b=affbMRf7wPppNNMUPDgm24GEuCkFwbkKNrxH0lVB3TSSdeCLGlVb9Z04BFHbesl0S GrjMX3t7/HCY02QnP1Ix0iDLSPq3uWSbQYVfoBTl8/TiFqh5D833amIvJn2ZN7hjp8 /8JcIrbka59q54r/RCKEfP3u1d7QVGOFo9CoSJM4= From: "ed at catmur dot uk" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107206] New: Bogus -Wuninitialized in std::optional Date: Mon, 10 Oct 2022 23:14:09 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ed at catmur dot uk 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=3D107206 Bug ID: 107206 Summary: Bogus -Wuninitialized in std::optional Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ed at catmur dot uk Target Milestone: --- Since 12, at -std=3Dc++17 -O -Wuninitialized: #include struct X { X() =3D default; X(X const& r) : i(r.i) {} int i; }; struct Y { Y() : x() {} X x; std::optional o; }; struct Z { Y y; explicit Z(Y y) : y(y) {} }; void f(Y const&); void test() { Y const y; Z z(y); z.y.o =3D 1; auto const w =3D z; f(w.y); } In copy constructor 'Y::Y(const Y&)', inlined from 'void test()' at :19:10: :7:8: warning: '*(int*)((char*)&y + offsetof(const Y, Y::o.std::optional::.std::_Optional_base::))' is used uninitialized [-Wuninitialized] 7 | struct Y { | ^ : In function 'void test()': :18:13: note: 'y' declared here 18 | Y const y; | ^ Most similar to #80635 and #86465, I think? Although this is -Wuninitialize= d, not -Wmaybe-uninitialized.=