title: Memory allocation for public and private fields - GCC way
body: <p><strong>This is not a duplicate of this</strong> <a href="https://stackoverflow.com/questions/25479373/how-memory-is-allocated-for-private-and-public-members-of-the-class">question</a>,
  I read the answers and I still have some questions about this subject.</p>
  
  <p>I tested some classes like this one:</p>
  
  <pre><code>class A {
  private:
      int b;
  
  public:
      char c;
      int a;
  
  private:
      char e;
  };
  </code></pre>
  
  <p>And I've seen that the fields are stored as if there were no access-specifier,
  this is not wrong since :</p>
  
  <p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3376.pdf" rel="nofollow noreferrer">N3376</a> (the first post C++11 draft) 9.2 [class.mem]/13:</p>
  
  <blockquote>
    <p>Nonstatic data members of a (non-union) class <strong>with the same access control</strong> (Clause 11) are allocated so that later members have higher addresses within a class object. The order of allocation of non-static data members with diﬀerent access control is unspeciﬁed. Implementation alignment requirements might cause two adjacent members not to be allocated immediately after each other; so might requirements for space for managing virtual functions (10.3) and virtual base classes (10.1).</p>
  </blockquote>
  
  <p>What I still don't understand is this :</p>
  
  <blockquote>
    <p><strong>The order of allocation of non-static data members with diﬀerent access control is unspeciﬁed.</strong></p>
  </blockquote>
  
  <p>What do they mean by unspecified, GCC certainly have a way of doing this, they don't just do it randomly I guess... They don't want the user to know it ?
  Or there is so many ways depending on the options maybe ?</p>
  
  <p>Because all the examples I tried, I had the same order as declared in my file (+ padding)</p>
  
  <p><strong>I am using gcc 4.9.2, Does anyone know if GCC specified their way of doing this ?</strong></p>
  
  <p>I need to know this because I am creating a program that calculates the padding between all fields, the program works with structures that have no access specifiers for the moment. I will have to find a way to do this when there is different accessibility blocks</p>