https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94058
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> --- This may implement that DR: --- a/gcc/cp/typeck2.cc +++ b/gcc/cp/typeck2.cc @@ -1012,6 +1012,14 @@ check_narrowing (tree type, tree init, tsubst_flags_t complain, if (TREE_CODE (ftype) == ENUMERAL_TYPE) /* Check for narrowing based on the values of the enumeration. */ ftype = ENUM_UNDERLYING_TYPE (ftype); + /* Undo convert_bitfield_to_declared_type. (STRIP_NOPS would not be + enough). */ + tree stripped_init = init; + while (CONVERT_EXPR_P (stripped_init)) + stripped_init = TREE_OPERAND (stripped_init, 0); + /* Core 2627 */ + if (is_bitfield_expr_with_lowered_type (stripped_init)) + ftype = TREE_TYPE (stripped_init); if ((tree_int_cst_lt (TYPE_MAX_VALUE (type), TYPE_MAX_VALUE (ftype)) || tree_int_cst_lt (TYPE_MIN_VALUE (ftype),