]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Initialize std::normal_distribution::_M_saved [PR 99536]
authorJonathan Wakely <jwakely@redhat.com>
Thu, 11 Mar 2021 16:43:51 +0000 (16:43 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 11 Mar 2021 17:52:55 +0000 (17:52 +0000)
This avoids a false positive -Wmaybe-uninitialized warning, by
initializing _M_saved on construction.

libstdc++-v3/ChangeLog:

PR libstdc++/99536
* include/bits/random.h (normal_distribution): Use
default-initializer for _M_saved and _M_saved_available.

libstdc++-v3/include/bits/random.h

index b74e9cfd5043fecfc0d1a14c4bba87b2b9bd3646..877ac3406b6ce090cb4b3cc2ac3675454707d2ed 100644 (file)
@@ -2024,12 +2024,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       explicit
       normal_distribution(result_type __mean,
                          result_type __stddev = 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 = 0;
+      bool        _M_saved_available = false;
     };
 
   /**