https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88274

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2018-11-30
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot 
gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
-fstrict-enums.  By inspection ranges_from_anti_range falls foul of our
incomplete honoring of TYPE_MIN/MAX_VALUE.  Don't have a cross ready
to test the following patch but it looks "obvious" ...

Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c      (revision 266657)
+++ gcc/tree-vrp.c      (working copy)
@@ -1249,14 +1249,14 @@ ranges_from_anti_range (const value_rang
       || !vrp_val_max (type))
     return false;

-  if (!vrp_val_is_min (ar->min ()))
-    *vr0 = value_range (VR_RANGE,
-                       vrp_val_min (type),
-                       wide_int_to_tree (type, wi::to_wide (ar->min ()) - 1));
-  if (!vrp_val_is_max (ar->max ()))
-    *vr1 = value_range (VR_RANGE,
-                       wide_int_to_tree (type, wi::to_wide (ar->max ()) + 1),
-                       vrp_val_max (type));
+  if (tree_int_cst_lt (vrp_val_min (type), ar->min ()))
+    vr0->set (VR_RANGE,
+             vrp_val_min (type),
+             wide_int_to_tree (type, wi::to_wide (ar->min ()) - 1));
+  if (tree_int_cst_lt (ar->max (), vrp_val_max (type)))
+    vr1->set (VR_RANGE,
+             wide_int_to_tree (type, wi::to_wide (ar->max ()) + 1),
+             vrp_val_max (type));
   if (vr0->undefined_p ())
     {
       *vr0 = *vr1;

Reply via email to