https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89192
Bug ID: 89192 Summary: -Wuninitialized doesn't warn about a vector initialization with uninitialized field Product: gcc Version: 8.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: Hi-Angel at yandex dot ru Target Milestone: --- # Steps to reproduce (in terms of terminal commands): $ cat test.cpp #include <vector> struct MyStruct { std::vector<char> vec; unsigned b; MyStruct(unsigned arg1): vec(b), b(arg1){} }; int main() { MyStruct m{1}; } $ g++ test.cpp -Wuninitialized -Wmaybe-uninitialized # Expected: A warning about `vec` being initialized in constructor with `b` field that is not yet initialized. # Actual The code silently compiles # Additional information The bug is specific to non-trivial types. E.g. if you replace `vector` with `unsigned`, the warning will work. However it doesn't for std∷vector or std∷list. It came up in a real project, where reorder of fields resulted in a bug that GCC doesn't warn about.