https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19808
Jason Merrill <jason at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #22 from Jason Merrill <jason at gcc dot gnu.org> --- (In reply to Manuel López-Ibáñez from comment #21) > I just got hit by this bug. This can obviously be warned in the FE as clang > does: > > test.cc:4:11: warning: field 'j' is uninitialized when used here > [-Wuninitialized] > S() : i(j), j(1) {} > ^ > > simply by marking the members somehow as initialized or not, and when using > them realizing that they are still uninitialized. > > Marek, Paolo, Jason? Any idea how to do this? It could be done specifically for uses in mem-initializers by walking the initializer in perform_mem_init to look for any references to members that haven't been marked yet. A more general warning that would cover, say, X x; x.x = x.y; would need support in the existing back end -Wuninitialized code.