------- Comment #14 from rguenther at suse dot de 2009-01-29 09:19 ------- Subject: Re: [4.4 regression] Unexplained "'<anonymous>' is used uninitialized in this function" warning in cc1plus -m64
On Wed, 28 Jan 2009, mmitchel at gcc dot gnu dot org wrote: > ------- Comment #13 from mmitchel at gcc dot gnu dot org 2009-01-28 23:56 > ------- > Actually, CLASSTYPE_EMPTY_P is probably a fine thing to use for C++. (It's of > course C++ specific; you'd either need to access it via a hook, or promote to > a > language-independent bit.) CLASSTYPE_EMPTY_P will not capture an array of > empty objects, but that's an extreme corner-case. > > Note that CLASSTYPE_EMPTY_P classes may have arbitrary size. That's because > of > things like: > > struct A{}; > struct B : public A {}; > struct C : public A, public B {}; > > In C, you cannot put the B sub-object at the same address as the A sub-object > since that would end up with two A sub-objects (the A-in-B-in-C subobject and > A-in-C subobject) at the same address. So, C will be a two-byte structure. > Obviously, you can generalize this to make arbitrarily huge empty classes. Ok. But, as opposed to inheritance, inserting empty members seems to make a class non-empty: struct A {}; struct B { A x; }; even if in the single-member case I would have expected it to behave like the single-inheritance case really. Note that cp_expr_size boils down to checking CLASSTYPE_EMPTY_P already, but in the member case doesn't seem to map to "does not need initialization". Richard. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38908