https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102700
Bug ID: 102700 Summary: [Diagnostics] uninitialized warning missing after O2 vectorization. Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: crazylht at gmail dot com Target Milestone: --- Host: x86_64-pc-linux-gnu testcase is from g++.dg/warn/Wuninitialized-13.C struct shared_count { shared_count () { } shared_count (shared_count &r) : pi (r.pi) { } // { dg-warning "\\\[-Wuninitialized" "" { xfail { i?86-*-* x86_64-*-* } } } int pi; }; // There's another (redundant) -Wuninitialized on the line below. struct shared_ptr { int ptr; shared_count refcount; }; struct Bar { Bar (int, shared_ptr); }; void g () { shared_ptr foo; Bar (0, foo); } After vectorization .C.211.uninit1 ;; Function g (_Z1gv, funcdef_no=6, decl_uid=4497, cgraph_uid=13, symbol_order=12) void g () { int * vectp.11; vector(2) int * vectp.10; vector(2) int vect__6.9; int * vectp.8; vector(2) int * vectp_foo.7; struct shared_ptr foo; struct shared_ptr D.4566; struct Bar D.4567; <bb 2> [local count: 1073741824]: [test2.C:6:19] MEM[(struct shared_count *)[test2.C:23:14] &foo + 4B] ={v} {CLOBBER}; [test2.C:13:8] vect__6.9_12 = MEM <vector(2) int> [(int *)&foo]; [test2.C:8:5] MEM[(struct shared_count *)[test2.C:24:3] &D.4566 + 4B] ={v} {CLOBBER}; [test2.C:13:8] MEM <vector(2) int> [(int *)&D.4566] = vect__6.9_12; [test2.C:24:3] Bar::Bar ([test2.C:24:3] &D.4567, 0, [test2.C:24:3] &D.4566); [test2.C:24:3] D.4567 ={v} {CLOBBER}; [test2.C:24:3] D.4566 ={v} {CLOBBER}; foo ={v} {CLOBBER}; [test2.C:25:1] return; } MEM <vector(2) int> [(int *)&foo]; is used instead of _6 = foo.ptr; which is missed by warn_uninitialized_vars?