TL DR
Both are correct.
The value of the enumeration is limited by the base type, not by counters!
C ++ 14, 7.2 Listing declarations, clause 8:
You can define an enumeration that has values that are not defined by any of its counters.
This means that you can:
state x = static_cast< state >(5);
This is what GCC warns about: enum statemay have values that do not fit into 2 bits.
However, until you try to do this with X::st, everything will be brilliant.
This is (possibly) why Klang does not warn you about this.
, .