https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101539
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 51186 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51186&action=edit gcc12-pr101539.patch So, I've tried to play with the __is_layout_compatible trait, here is the result. There is one known bug, the C++ FE unfortunately removes zero sized bit-fields early, for layout compatibility we need them (and now just that they were present but how many as well and their types). Can we not remove them or remove them when the FE parses the whole TU? The testcase also contains various cornercases where layout-compatibility as currently defined is just weird.