https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19808
--- Comment #40 from Jason Merrill <jason at gcc dot gnu.org> --- (In reply to Richard Biener from comment #39) > so - how do I make X::X used and thus prevail? It looks like it doesn't > really exist True, for C++14 and up, "X x{};" does aggregate initialization rather than calling the constructor. We ought to warn about this at function scope, but we clear the object first, so it isn't actually uninitialized. As you found, removing the {} makes it use the constructor. > OK, doing void foo() { X x; } shows > > X::X (struct X * const this) > { > _1 = this->x2; > this->x1 = _1; > this->x2 = 0; > } > > foo () > { > struct X x; > > try > { > X::X (&x); > } > finally > { > x = {CLOBBER}; > } > } > > warning would need inlining of the constructor which only happens after > the early warning pass, the late one isn't run at -O0 and with optimization > everything of course vanishes. I was wondering about a maybe-uninitialized warning for the constructor without considering where it's called from; even if a particular object is zero-initialized when we enter the implicit constructor, the constructor shouldn't rely on that. Basically, warn as if there were a clobber, without there actually being one.