public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99536] New: unexplained warning on "uninitialized value"
@ 2021-03-11  1:36 wuz73 at hotmail dot com
  2021-03-11 13:30 ` [Bug c++/99536] unexplained warning on "uninitialized value" in std::normal_distribution redi at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: wuz73 at hotmail dot com @ 2021-03-11  1:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99536

            Bug ID: 99536
           Summary: unexplained warning on "uninitialized value"
           Product: gcc
           Version: 5.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wuz73 at hotmail dot com
  Target Milestone: ---

Although the example in
http://www.cplusplus.com/reference/random/normal_distribution/ compiled fine, I
got a warning on uninitialized value in a similar code below.

#include <random>
void foo(double);
int main()
{
  std::default_random_engine generator;
  std::normal_distribution<double> norm_dist(0,1);
  for(int i=0; i<3; i++)
    foo(norm_dist(generator));
  return 0;
}

When compiled with "g++ -std=c++11 -Wall -ffast-math -O -c foo.cpp" using
gcc5.3.1 on CentOS7.2, I got:

foo.cpp:8:30: warning: ‘norm_dist.std::normal_distribution::_M_saved’ may be
used uninitialized in this function [-Wmaybe-uninitialized]
foo(norm_dist(generator));

Note that without -O, -ffast-math, or the for-loop, the code compiled fine
without any warning.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-08-06  2:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11  1:36 [Bug c++/99536] New: unexplained warning on "uninitialized value" wuz73 at hotmail dot com
2021-03-11 13:30 ` [Bug c++/99536] unexplained warning on "uninitialized value" in std::normal_distribution redi at gcc dot gnu.org
2021-03-11 15:09 ` redi at gcc dot gnu.org
2021-03-11 17:53 ` cvs-commit at gcc dot gnu.org
2021-03-11 18:18 ` redi at gcc dot gnu.org
2021-03-29 20:03 ` cvs-commit at gcc dot gnu.org
2021-03-29 21:37 ` redi at gcc dot gnu.org
2021-04-07 21:16 ` [Bug tree-optimization/99536] " msebor at gcc dot gnu.org
2021-04-07 21:18 ` msebor at gcc dot gnu.org
2021-04-20 18:52 ` cvs-commit at gcc dot gnu.org
2022-08-06  2:57 ` wuz73 at hotmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).