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.