From: Jakub Jelinek Date: Thu, 13 Apr 2017 19:52:58 +0000 (+0200) Subject: re PR sanitizer/80403 (UBSAN: compile time crash with "type mismatch in binary expres... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=099560172fc6d46fcd7878043acab799d4fb044f;p=gcc.git re PR sanitizer/80403 (UBSAN: compile time crash with "type mismatch in binary expression" message in / and % expr) PR sanitizer/80403 * fold-const.c (fold_ternary_loc): Revert use op0 instead of fold_convert_loc (loc, type, arg0) part of 2017-04-12 change. * g++.dg/ubsan/pr80403-2.C: New test. From-SVN: r246917 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ca93f9bf21e..33b094e56f5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-04-13 Jakub Jelinek + + PR sanitizer/80403 + * fold-const.c (fold_ternary_loc): Revert + use op0 instead of fold_convert_loc (loc, type, arg0) part of + 2017-04-12 change. + 2017-04-13 Vladimir Makarov PR rtl-optimization/80343 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index fb0b1a6afc3..770162251f2 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -11544,7 +11544,7 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type, && (code == VEC_COND_EXPR || !VECTOR_TYPE_P (type))) return fold_build2_loc (loc, code == VEC_COND_EXPR ? BIT_AND_EXPR : TRUTH_ANDIF_EXPR, - type, op0, op1); + type, fold_convert_loc (loc, type, arg0), op1); /* Convert A ? B : 1 into !A || B if A and B are truth values. */ if (code == VEC_COND_EXPR ? integer_all_onesp (op2) : integer_onep (op2) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4f46db8091f..07902c16576 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-04-13 Jakub Jelinek + + PR sanitizer/80403 + * g++.dg/ubsan/pr80403-2.C: New test. + 2017-04-13 Vladimir Makarov PR rtl-optimization/80343 diff --git a/gcc/testsuite/g++.dg/ubsan/pr80403-2.C b/gcc/testsuite/g++.dg/ubsan/pr80403-2.C new file mode 100644 index 00000000000..434a883dbe9 --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/pr80403-2.C @@ -0,0 +1,14 @@ +// PR sanitizer/80403 +// { dg-do compile } +// { dg-options "-fsanitize=undefined" } + +extern const long long int v; +extern unsigned long int w; + +int +foo () +{ + int a = (0 - 40U <= (0 == 8)) << !w << (0 < v) == 0; + int b = ((0 ^ 0) < (long) (1066066618772207110 <= 0)) / 0 << 0; // { dg-warning "division by zero" } + return a + b; +}