There is no difference. The Standard's rules apply to all subobjects, whether they are base subobjects, member subobjects, or even the elements of an array.
> The compiler is free to rearrange their layout however it sees fit for a compact memory and to avoid extra instruction to fetch a member if it is not at the right memory boundary.
> Imagine this situation:
> struct object
> {
> char c;
> int i;
> short s;
> };
>
> Obviously the compiler can, and maybe must, move the char member object, to the end of the list of members and add some padding to make the memory compact and at 4's. Making the order of initialization irrelevant.
No. `struct object` here is a standard-layout type. The standard guarantees that c, i, s are laid out in that order, and in fact that offsetof(object, c)==0.
Again, you can read all about the rules of C++
- in the standard
- on cppreference
- in a vast number of blog posts and articles
- in a vast number of videos online
> [...] So, i think we need to make the order of initialization of data members, irrelevant. And separate it from the subobjects initialization.
> And keep all the rest.
> What do you think?
That paragraph is a proposal of how you (currently) think C++ should work. As a proposal, it's on-topic for std-proposals.
But, it's fundamentally unworkable. (See Chris Ryan's explanation, two messages up from this one.) So, it's a bad idea.
Please, stop arguing with all the experts until you have played around with C++ on
godbolt.org a little bit and seen with your own eyes how things work in this language.
–Arthur