title: C++ sizeof with bool
body: <p>It is a simple question. Code first.</p>
  
  <pre><code>struct A {
      int x; 
  };
  struct B {
      bool y;
  };
  struct C {
      int x;
      bool y;
  };
  </code></pre>
  
  <p>In main function, I call</p>
  
  <pre><code>cout &lt;&lt; " bool : " &lt;&lt; sizeof(bool) &lt;&lt;
       "\n int : " &lt;&lt; sizeof(int) &lt;&lt;
       "\n class A : " &lt;&lt; sizeof(A) &lt;&lt;
       "\n class B : " &lt;&lt; sizeof(B) &lt;&lt;
       "\n class C : " &lt;&lt; sizeof(C) &lt;&lt; "\n";
  </code></pre>
  
  <p>And the result is </p>
  
  <pre><code>bool : 1
  int : 4
  class A : 4
  class B : 1
  class C : 8
  </code></pre>
  
  <p>Why is the size of class C 8 instead of 5?
  Note that this is compiled with gcc in MINGW 4.7 / Windows 7 / 32 bit machine.</p>