https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78141
Bug ID: 78141 Summary: Missing uninitialized warning about struct member after change another struct definition (without optimization) Product: gcc Version: 5.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: vmario1986 at gmail dot com Target Milestone: --- Created attachment 39917 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39917&action=edit Example code demonstrating the issue I compile this simple program: #include <cstdio> #include <iostream> using namespace std; struct Foo { int a; int b; }; struct Bar { //Bar() = default; int d; }; int main() { Foo foo; Bar bar; printf("%d %d\n", foo.a, foo.b); return 0; } and I get those warnings: $ g++ -std=c++11 -Wall -Wextra -Wpedantic foo.cpp -o foo foo.cpp: In function ‘int main()’: foo.cpp:21:9: warning: unused variable ‘bar’ [-Wunused-variable] Bar bar; ^ foo.cpp:23:11: warning: ‘foo.Foo::b’ is used uninitialized in this function [-Wuninitialized] printf("%d %d\n", foo.a, foo.b); ^ foo.cpp:23:11: warning: ‘foo.Foo::a’ is used uninitialized in this function [-Wuninitialized] Of course, this is what we expect. But when I uncomment the Bar default ctor, there is a problem - all warnings disappear. With -O1, -O2, -O3 and -Os my code gives warnings in both cases. I have posted this issue on the Stack Overflow and users found this issue on GCC 6.1.0 too.