+2015-10-29 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/56956
+ * fold-const.c (fold_cond_expr_with_comparison): Do not fold
+ unsigned conditonal negation to ABS_EXPR.
+
2015-10-29 Richard Biener <rguenther@suse.de>
* gimple-match-head.c (gimple_simplify): Remove premature checking
case GE_EXPR:
case GT_EXPR:
if (TYPE_UNSIGNED (TREE_TYPE (arg1)))
- arg1 = fold_convert_loc (loc, signed_type_for
- (TREE_TYPE (arg1)), arg1);
+ break;
tem = fold_build1_loc (loc, ABS_EXPR, TREE_TYPE (arg1), arg1);
return pedantic_non_lvalue_loc (loc, fold_convert_loc (loc, type, tem));
case UNLE_EXPR:
case LE_EXPR:
case LT_EXPR:
if (TYPE_UNSIGNED (TREE_TYPE (arg1)))
- arg1 = fold_convert_loc (loc, signed_type_for
- (TREE_TYPE (arg1)), arg1);
+ break;
tem = fold_build1_loc (loc, ABS_EXPR, TREE_TYPE (arg1), arg1);
return negate_expr (fold_convert_loc (loc, type, tem));
default:
+2015-10-29 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/56956
+ * c-c++-common/ubsan/pr56956.c: New testcase.
+
2015-10-28 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/discr44.adb: New test.
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-fsanitize=undefined -fsanitize-undefined-trap-on-error" } */
+
+unsigned int __attribute__((noinline,noclone))
+foo (unsigned int x)
+{
+ return x <= __INT_MAX__ ? x : -x;
+}
+
+int
+main ()
+{
+ volatile unsigned int tem = foo (-__INT_MAX__ - 1);
+ return 0;
+}