This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

empty member optimization?


In answer to something Jason posted a couple of weeks ago...

I don't know of anything in the Draft that forbids eliding
storage of empty member objects that are followed by an
access specifier, or at the end of the object:

  struct Empty {};

  struct Not {
    Empty e;
   public:
    int i;
  };

Here members i and e could have the same address.  However, it
gets complicated, because in

  struct Not2 {
    Empty e;
   public:
    Empty f;
  };

  struct Not3 : Not2 {
    Empty g;
  };

You have to make sure e, f, and g have distinct addresses.
But these quibbles don't seem very different from what you 
have with empty bases:

  struct Not4 : Empty {
    Empty h;    
  };

Nathan Myers
ncm@cygnus.com



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]