------- Comment #11 from mmitchel at gcc dot gnu dot org 2005-11-06 00:55 ------- I thought that a key observation is that we only need to know (a) what empty subobjects are at offset zero, and (b) what empty subobjects occur before the location where we will next place a non-empty field or base. Therefore, we can avoid recording the offsets for any of the empty objects in the array other than those at offset zero.
However, I forgot that empty classes do not necessarily have size one: class A {}; class B : public A {}; class C : public A, public B {}; // C empty, sizeof (C) == 2 So, the observation above has to be modified -- instead of just offset zero we must care about empty objects at offsets < N, where N is the sizeof the largest empty class we have thus far encountered in the translation unit. That should still permit very considerable improvement. I plan to work on implementing this improvement soon. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21308