Quuxplusone added a comment. > Any runtime penalty? (Usually compilers choose a faster underlying type for > enums, not smaller)
> The decision is made in the header (so I think it will always be `int` until > this doesn't fit). To decide what is faster the compiler would need to know > all the usages. Which it can't. Yes, Clang chooses `int` by default. In fact, C++11 and later //mandate// that a new-style scoped enum `enum class Foo {` means the same thing as `enum class Foo : int {` — see https://timsong-cpp.github.io/cppwp/n3337/dcl.enum#5 . For unscoped old-style enums, Clang/GCC/MSVC all choose `int` by default, //unless// `-fshort-enums` is passed on the command line and/or the enum is annotated with `__attribute__((packed))`, in which case it chooses the smallest possible type. `-fshort-enums` and `__attribute__((packed))` have no effect on new-style scoped enums nor on enums with explicit underlying types. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D120398/new/ https://reviews.llvm.org/D120398 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits