title: Packing bitfields even more tightly
body: <p>I have a problem with bitfields in derived classes.</p>
  
  <p>With the g++ compiler, you can assign <code>__attribute__((packed))</code> to a class and it will pack bitfields. So</p>
  
  <pre><code>class A
  {
    public:
      int one:10;
      int two:10;
      int three:10;
  } __attribute__ ((__packed__));
  </code></pre>
  
  <p>takes up only 4 bytes. So far, so good.<br>
  However, if you inherit a class, like this</p>
  
  <pre><code>class B
  {
    public:
      int one:10;
      int two:10;
  } __attribute__ ((__packed__));
  
  class C : public B
  {
    public:
      int three:10;
  } __attribute__ ((__packed__));
  </code></pre>
  
  <p>I would expect class C, which has the same content as class A above, to have the same layout as well, i.e. take up 4 bytes. However, C turns out to occupy 5 bytes.</p>
  
  <p>So my question is, am I doing something wrong, and if so, what? Or is this a problem with the compiler? An oversight, a real bug?</p>
  
  <p>I tried googling, but haven't really come up with anything, apart from a difference between Linux and Windows (where the compiler tries to emulate MSVC), which I'm not interested in. This is just on Linux.</p>