https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82307
Mukesh Kapoor <mukesh.kapoor at oracle dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mukesh.kapoor at oracle dot com --- Comment #4 from Mukesh Kapoor <mukesh.kapoor at oracle dot com> --- This seems to be a problem in integral promotion in function type_promotes_to(). The following change fixes the bug: --- gcc/cp/cvt.c (revision 253270) +++ gcc/cp/cvt.c (working copy) @@ -1854,11 +1854,15 @@ tree prom = type; if (TREE_CODE (prom) == ENUMERAL_TYPE) prom = ENUM_UNDERLYING_TYPE (prom); - if (TYPE_UNSIGNED (prom) - && ! int_fits_type_p (TYPE_MAX_VALUE (prom), totype)) - prom = c_common_type_for_size (precision, 1); - else - prom = totype; + // If enum has fixed underlying type, use that type (bug 82307) + if (!ENUM_FIXED_UNDERLYING_TYPE_P (type)) + { + if (TYPE_UNSIGNED (prom) + && ! int_fits_type_p (TYPE_MAX_VALUE (prom), totype)) + prom = c_common_type_for_size (precision, 1); + else + prom = totype; + } if (SCOPED_ENUM_P (type)) { if (abi_version_crosses (6)