Alexei Starovoitov writes: > On Thu, Jun 6, 2024 at 3:51 AM Cupertino Miranda > <cupertino.miranda@xxxxxxxxxx> wrote: >> >> GCC will allocate variables in a different order then clang and when >> comparing content is not where comparisson is expecting. >> >> Some other test, would expect that struct fields would be in some >> particular order, while GCC decides it would benefit from reordering >> struct fields. For passing those tests I need to disable GCC >> optimization that would make this reordering. >> However reordering of the struct fields is a perfectly valid >> optimization. Maybe disabling for this tests is acceptable, but in any >> case the test itself is prune for any future optimizations that can be >> added to GCC or CLANG. > > Not really. > Allocating vars in different order within a section is fine, > but compilers are not allowed to reorder fields within structs. > There is a plugin for gcc that allows opt-in via > __attribute__((randomize_layout)). > But never by default. Apologies for the mess up. Indeed the reordering happens on variable declarations. In prog/test_core_autosize.c, it declares variables and in prog_tests/core_autosize.c it checks content with a "template" struct that should map how the data is layout in memory. Somehow I miss remembered the actual problem and got confused with what was actually being reorderd. In the end both examples are the same.