GCC 7 and earlier, when targeting MinGW, seems to have a bug in layout/size of bitfield structs if they contain a nested enum, making the size of the struct 8 bytes, while we have a static assert requiring it to be 4 bytes or less.
While this clearly is a GCC bug, the workaround (moving the enum out of the bitfield) also is very nonintrusive and matches other existing enums there.
Testcase:
$ cat bitfield.cpp struct MyStruct { unsigned a : 1; enum { SomeValue = 42 }; unsigned b : 1; }; int StructSize = sizeof(struct MyStruct); $ x86_64-w64-mingw32-g++ -S -o - bitfield.cpp | grep -C 2 StructSize .file "bitfield.cpp" .text .globl StructSize .data .align 4 StructSize: .long 8 .ident "GCC: (GNU) 7.3-win32 20180312"