https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105820
--- Comment #4 from Andrew Macleod <amacleod at redhat dot com> --- Well, thats not really the problem here. We are casting [irange] gimple_code [2, 2] to a gimple_code, and getting: [irange] gimple_code VARYING Couple of issues.. one, we shouldnt bother casting anything if the types are already the same... but still.. the result is incorrect. Tracing it down, it looks like during the casting process, we call: operator_cast::inside_domain_p so see if a min == 2, max == 2, is inside the range of [irange] gimple_code VARYING. THe routine returns false because with strict enum on, we get the min and max of the domain from: wide_int domain_min = wi::to_wide (vrp_val_min (range.type ())); wide_int domain_max = wi::to_wide (vrp_val_max (range.type ()));, which boils down to TYPE_MIN_VALUE (gimple_code) and TYPE_MAX_VALUE (gimple_code) p range.type () $29 = (tree_node *) 0x7fffe9f77c78 (gdb) p print_generic_expr (stderr, $29, 0) gimple_code (gdb) p print_generic_expr (stderr, $29->type_non_common.minval, 0) 0 (gdb) p print_generic_expr (stderr, $29->type_non_common.maxval, 0) 1 So the min value for the enum is set correctly to 0, but the max is set to 1... thus the routine determines that [2, 2] is not within the range of [0, 1] and returns varying.. It seems like the max value for the enum is not being set correctly? If I check right at the point of the failure: (gdb) frame 1 #1 0x0000000001c9c4fe in irange::invert (this=0x7fffffff1570) at /home/gcc/master/gcc/gcc/value-range.cc:2185 2185 gcc_checking_assert (!undefined_p () && !varying_p ()); (gdb) p type() $42 = (tree_node *) 0x7fffe9f77c78 (gdb) p print_generic_expr (stderr, type(), 0) gimple_code (gdb) p print_generic_expr (stderr, type()->type_non_common.maxval, 0) 1