From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 79F8F388C033; Thu, 11 Mar 2021 13:30:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 79F8F388C033 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99536] unexplained warning on "uninitialized value" in std::normal_distribution Date: Thu, 11 Mar 2021 13:30:35 +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: 5.3.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org 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: 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, 11 Mar 2021 13:30:35 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99536 --- Comment #1 from Jonathan Wakely --- GCC 5 is old and no longer supported. This is probably a jump threading bug. The _M_saved member is only ever use= d if _M_saved_available says it can be used, and that is only the case after it's been initialized. We could probably just initialize it on construction to avoid the false positive warning: --- a/libstdc++-v3/include/bits/random.h +++ b/libstdc++-v3/include/bits/random.h @@ -2024,12 +2024,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit normal_distribution(result_type __mean, result_type __stddev =3D result_type(1)) - : _M_param(__mean, __stddev), _M_saved_available(false) + : _M_param(__mean, __stddev) { } explicit normal_distribution(const param_type& __p) - : _M_param(__p), _M_saved_available(false) + : _M_param(__p) { } /** @@ -2166,8 +2166,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const param_type& __p); param_type _M_param; - result_type _M_saved; - bool _M_saved_available; + result_type _M_saved =3D 0; + bool _M_saved_available =3D false; }; /**=