2017-06-20 Richard Biener <rguenther@suse.de>
PR middle-end/81097
* fold-const.c (split_tree): Fold to type before negating.
* c-c++-common/ubsan/pr81097.c: New testcase.
From-SVN: r249407
+2017-06-20 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/81097
+ * fold-const.c (split_tree): Fold to type before negating.
+
2017-06-20 David Malcolm <dmalcolm@redhat.com>
* diagnostic-show-locus.c
&& code == PLUS_EXPR)
{
/* -X - 1 is folded to ~X, undo that here. Do _not_ do this
- when IN is constant. */
- *minus_litp = build_one_cst (TREE_TYPE (in));
- var = negate_expr (TREE_OPERAND (in, 0));
+ when IN is constant. Convert to TYPE before negating. */
+ *minus_litp = build_one_cst (type);
+ var = negate_expr (fold_convert_loc (loc, type, TREE_OPERAND (in, 0)));
}
else
var = in;
+2017-06-20 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/81097
+ * c-c++-common/ubsan/pr81097.c: New testcase.
+
2017-06-20 Richard Biener <rguenther@suse.de>
* gcc.dg/vect/pr65947-9.c: Adjust.
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-fsanitize=undefined -fsanitize-undefined-trap-on-error" } */
+
+unsigned int a = 3309568;
+unsigned int b = -1204857327;
+short c = -10871;
+short x;
+int main()
+{
+ x = ((short)(~a) | ~c) + ((short)(~b) | ~c);
+ return 0;
+}