------- 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.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38908

Reply via email to