From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 776E13858C5E; Fri, 22 Dec 2023 08:15:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 776E13858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703232929; bh=NNtEdKQ5TZRPRj5dCdxJqeeMHFtwg5SxK+L96BSR9uw=; h=From:To:Subject:Date:From; b=GZPFivExucieOR+pAxXUepuv99qoEj5WdMtm8KlBCRYZKaQNXQmEeLKHC/qjV8uwf 5sf8acWuQKocRlCWSKhpqQRYH8eDH+6//cc7ALTy8+nogieduvbfpz6achiUmItLfH plLeHTSGo5bPxQybWamWDx44AZBxzztI2zIO6vJU= From: "MikeSmith32564 at mail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113111] New: -Werror=uninitialized is not consistent for optimization level 0 or -std=before-c++20 Date: Fri, 22 Dec 2023 08:15:26 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: MikeSmith32564 at mail 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: --- 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=3D113111 Bug ID: 113111 Summary: -Werror=3Duninitialized is not consistent for optimization level 0 or -std=3Dbefore-c++20 Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: MikeSmith32564 at mail dot com Target Milestone: --- The following snippet: #include #include struct Dummy { std::string val; }; int main() { Dummy d =3D { d.val =3D "random text #########################################################" }; std::cout<::_M_string_length' is used uninitialized [-Werror=3Duninitialized] 1084 | { return _M_string_length; } | ^~~~~~~~~~~~~~~~ The example triggers undefined behavior when executed of course due to runn= ing std::string::operator=3D with the this pointer pointing to uninitialized me= mory but I believe a warning should be raised when building regardless of the optimization level selected. Strangely, standards before c++20 also do not report the warning.=