https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97360
--- Comment #13 from Andrew Macleod <amacleod at redhat dot com> --- Created attachment 49386 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49386&action=edit Patch to create integral MAX and MiN Joy. I'll try it and see what happens. And back to the first problem where the MIN and MAXs are not the right type. I found this nugget in tree.c::build_distinct_type_copy () /* Note that it is now possible for TYPE_MIN_VALUE to be a value whose TREE_TYPE is not t. This can also happen in the Ada frontend when using subtypes. */ What? That seems ridiculous, especially for types that are now distinct. Why on earth don't we create new MIN and MAX values for the type? I'm trying the attached patch which at least corrects it for integral types.. and does resolve the compilation failure. Is this the correct way to resolve this, or am I missing something else? + if (INTEGRAL_TYPE_P (type)) + { + TYPE_MIN_VALUE (t)= wide_int_to_tree (t, wi::to_wide (TYPE_MIN_VALUE (type))); + TYPE_MAX_VALUE (t)= wide_int_to_tree (t, wi::to_wide (TYPE_MAX_VALUE (type))); + } +