This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/86190] [6/7/8/9 Regression] -Wsign-conversion ignores explicit conversion in some cases


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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The warning is produced in
 5350   if (! converted)
 5351     {
 5352       if (TREE_TYPE (op0) != result_type)
 5353         op0 = cp_convert_and_check (result_type, op0, complain);
 5354       if (TREE_TYPE (op1) != result_type)
 5355         op1 = cp_convert_and_check (result_type, op1, complain);
which we didn't enter before, because of this hunk:
@@ -5028,20 +5022,12 @@ cp_build_binary_op (location_t location,

       if (short_compare)
    {
-     /* Don't write &op0, etc., because that would prevent op0
-        from being kept in a register.
-        Instead, make copies of the our local variables and
-        pass the copies by reference, then copy them back afterward.  */
-     tree xop0 = op0, xop1 = op1, xresult_type = result_type;
+     /* We call shorten_compare only for diagnostic-reason.  */
+     tree xop0 = fold_simple (op0), xop1 = fold_simple (op1),
+          xresult_type = result_type;
      enum tree_code xresultcode = resultcode;
-     tree val
-       = shorten_compare (location, &xop0, &xop1, &xresult_type,
+     shorten_compare (location, &xop0, &xop1, &xresult_type,
                   &xresultcode);
-     if (val != 0)
-       return cp_convert (boolean_type_node, val, complain);
-     op0 = xop0, op1 = xop1;
-     converted = 1;
-     resultcode = xresultcode;
    }

       if ((short_compare || code == MIN_EXPR || code == MAX_EXPR)

so converted is now 0 whereas before it was 1.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]