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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Like with

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 1335da5e9bc..aaa56697f29 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5322,7 +5322,6 @@ cp_build_binary_op (location_t location,
        }

       if ((short_compare || code == MIN_EXPR || code == MAX_EXPR)
-         && warn_sign_compare
          /* Do not warn until the template is instantiated; we cannot
             bound the ranges of the arguments until that point.  */
          && !processing_template_decl
@@ -5336,12 +5335,15 @@ cp_build_binary_op (location_t location,
          tree oop0 = maybe_constant_value (orig_op0);
          tree oop1 = maybe_constant_value (orig_op1);

-         if (TREE_CODE (oop0) != INTEGER_CST)
-           oop0 = cp_fully_fold (orig_op0);
-         if (TREE_CODE (oop1) != INTEGER_CST)
-           oop1 = cp_fully_fold (orig_op1);
-         warn_for_sign_compare (location, oop0, oop1, op0, op1, 
-                                result_type, resultcode);
+         if (warn_sign_compare)
+           {
+             if (TREE_CODE (oop0) != INTEGER_CST)
+               oop0 = cp_fully_fold (orig_op0);
+             if (TREE_CODE (oop1) != INTEGER_CST)
+               oop1 = cp_fully_fold (orig_op1);
+             warn_for_sign_compare (location, oop0, oop1, op0, op1, 
+                                    result_type, resultcode);
+           }
        }
     }

Reply via email to