EDIT: I read the quote incorrectly, the compiler is allowed to do this in 9.2/14 :
Non-static data members of a (non-unitary) class with the same access (Section 11) are allocated so that later members have higher addresses inside the class object. The distribution order of non-static data members with different access control is not defined (11). Implementation alignment requirements can cause two neighboring members not to stand out immediately after each other; so space requirements for managing virtual functions (10.3) and virtual base classes (10.1)
What he cannot do is reorder the attributes with the same access specifier.
This says that I donβt know of any implementation that allows itself to change the order of attributes even by access specifiers.
source share