erichkeane added a comment.
> In D130058#3714882 <https://reviews.llvm.org/D130058#3714882>, @glandium > wrote: > >> Also not caught: a cast of 0 when 0 is not a valid value in the enum. > > I don't think that situation will ever be UB. When the underlying type of the > enum is not fixed, the range of values it can represent is whatever values > fit into a hypothetical bit-field that is large enough to cover the full > range of stated values (https://eel.is/c++draft/enum#dcl.enum-8.sentence-2). > `0` is something that can always be represented in such a bit-field (there's > a special provision for empty enumerations or one that can only store 0). Correct here. A 'valid value' of an enum is NOT just the list of values listed. It is every value that would be represent-able by the smallest-bit-sized bitfield required to represent all of the possible enumerators. Since `0` is represent-able by all 1+ bit integers, zero is always valid. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D130058/new/ https://reviews.llvm.org/D130058 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits