+2017-05-19 Marek Polacek <polacek@redhat.com>
+
+ PR sanitizer/80800
+ * fold-const.c (extract_muldiv_1) <case TRUNC_DIV_EXPR>: Add
+ TYPE_OVERFLOW_WRAPS checks.
+
2017-05-19 Thomas Schwinge <thomas@codesourcery.com>
* tree-core.h (enum omp_clause_default_kind): Add
new operation. Likewise for the RHS from a MULT_EXPR. Otherwise,
do something only if the second operand is a constant. */
if (same_p
+ && TYPE_OVERFLOW_WRAPS (ctype)
&& (t1 = extract_muldiv (op0, c, code, wide_type,
strict_overflow_p)) != 0)
return fold_build2 (tcode, ctype, fold_convert (ctype, t1),
fold_convert (ctype, op1));
else if (tcode == MULT_EXPR && code == MULT_EXPR
+ && TYPE_OVERFLOW_WRAPS (ctype)
&& (t1 = extract_muldiv (op1, c, code, wide_type,
strict_overflow_p)) != 0)
return fold_build2 (tcode, ctype, fold_convert (ctype, op0),
+2017-05-19 Marek Polacek <polacek@redhat.com>
+
+ PR sanitizer/80800
+ * c-c++-common/ubsan/pr80800.c: New test.
+ * c-c++-common/Wduplicated-branches-1.c: Adjust an expression.
+
2017-05-19 Thomas Schwinge <thomas@codesourcery.com>
* c-c++-common/goacc/default-1.c: Update.
--- /dev/null
+/* PR sanitizer/80800 */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=undefined -fsanitize-undefined-trap-on-error" } */
+
+int n = 20000;
+int z = 0;
+
+int
+fn1 (void)
+{
+ return (n * 10000 * z) * 50;
+}
+
+int
+fn2 (void)
+{
+ return (10000 * n * z) * 50;
+}
+
+int
+main ()
+{
+ fn1 ();
+ fn2 ();
+}