https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78391
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |12.0 Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=19808 Status|NEW |ASSIGNED Component|c++ |middle-end --- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> --- In bug 19808 comment #38 Jason explains why the CLOBBER isn't present in the constructor, so that's not a bug. In light of that, I'm not sure the request can be implemented without introducing what are strictly speaking false positives like those Clang suffers from. In the test case below, the global a is implicitly zeroed out first and then its members are explicitly assigned, so there is no uninitialized read. At the same time, I suspect the result of this initialization is probably not going to be what the author intended, and so warning on it regardless might actually be useful (admittedly, issuing -Wuninitialized in this case would be a bit misleading). So with that, -Wuninitialized or -Wmaybe-uninitialized in the middle end could be probably enhanced to detect this pattern of intialization dependencies. Marek submitted a C++ patch for a subset of pr19808 last November but I'm not sure it handled this case. The patch was also not approved as Jason's preference was to detect these things in the middle end. So let me reassign this back to the middle end and try to remember to get to it for GCC 12. $ cat t.C && clang -S t.C struct A { int x = w; int w = 10; }; A a; t.C:1:20: warning: field 'w' is uninitialized when used here [-Wuninitialized] struct A { int x = w; int w = 10; }; ^ t.C:3:3: note: in implicit default constructor for 'A' first required here A a; ^ t.C:1:8: note: during field initialization in the implicit default constructor struct A { int x = w; int w = 10; }; ^ 1 warning generated.