From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C442F3986416; Thu, 17 Nov 2022 11:49:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C442F3986416 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668685765; bh=LtyvfqDbtc1y9a+C4x+842JGZA6T6CfdOFGFr2V0IEw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xi9jgj+YGLx1xyD9BlEozchnlBLT9aoxKNvdAOwsSDIr8Koi61/cGptJUGW1vbCyu bbtCJ35fk6KSIBYmTDbw1auWp2oP9A0V6vGqA9uIav92fdVDvj0GKEAhYLGGGGM6N7 ey0C4w4COZRqIvWYQLsq31Tggl3ScXLoXhDf0gRA= From: "marco.clemencic at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107138] [12/13 regression] std::variant triggers false-positive 'may be used uninitialized' warning Date: Thu, 17 Nov 2022 11:49:24 +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.2.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: marco.clemencic at gmail dot com 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: 12.3 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107138 --- Comment #4 from Marco Clemencic --- I have a similar problem with this chunk of code: ``` #include #include #include #include #include struct Wrapper { using Map =3D std::map; using Value =3D std::variant; Wrapper(Value v) : data{std::move(v)} {} Value data; }; auto f() { Wrapper::Map r; return std::make_unique(std::move(r)); // <- warning here // return std::make_unique(r); // <- no warning // return Wrapper(std::move(r)); // <- no warning } ``` but the uninitialized variable is coming from std::unique_ptr. As in the original report it works with gcc 11.3, but it fails with gcc12.2= and trunk (in my case already with -O1), see https://godbolt.org/z/bfo9vsEPc I attached the .ii produced by my test case.=