https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102586
--- Comment #16 from Jason Merrill <jason at gcc dot gnu.org> --- Created attachment 52410 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52410&action=edit sketch of vbase handling This is roughly what I had in mind, though it's algorithmically poor because it walks all the bases each time. But then it occurred to me that unless we know the complete object type, we don't know whether we're dealing with a base subobject, and risk clearing too much: struct C1 { virtual void f() {} char d; }; // vfn to make non-layout-POD struct C2: C1 { char c; }; __attribute__((noipa)) void foo (C1 *q) { __builtin_clear_padding (q); } int main() { C2 c2; c2.c = 42; foo (&c2); if (c2.c != 42) __builtin_abort(); } Because of this, I think we probably want __builtin_clear_padding to reject arguments that point to non-trivially-copyable type. And then we don't need to worry about vbases.