title: C++ 4 bytes aligned data
body: <p>This question is related to <a href="https://stackoverflow.com/questions/2124514/how-to-ensure-a-member-is-4-byte-aligned">How to ensure a member is 4-byte aligned?</a></p>
  
  <p>Example:</p>
  
  <pre><code>struct Aligned
  {
      char c;
      __attribute__((__aligned__(4))) int32_t member;
  }
  
  struct Test
  {
      char    c;
      Aligned s;//is s.member 4 bytes aligned?
  }
  
  
  void f1()
  {
      char    c1;
      Aligned s;//is s.member 4 bytes aligned?
      char    c2;
  }
  
  void f2()
  {
      Aligned* s = new Aligned();//is s.member 4 bytes aligned?
  }
  </code></pre>
  
  <p>Can you please explain if "member" is 4 bytes aligned in all cases, and if yes how this works?</p>
  
  <p>Edit:
  I forgot the case where Aligned is derived from other struct:</p>
  
  <pre><code>struct Aligned : public SomeVariableSizeStruct
  {
      char c;
      __attribute__((__aligned__(4))) int32_t member;
  }
  </code></pre>
  
  <p>Second Edit: My questions is: is always first member of a structure 4 bytes aligned? Because in all cases presented here the first variable address might not be 4 bytes aligned and the 3 bytes padding doesn't guarantee that "member" is 4 bytes aligned</p>