Commit 3902bce0 by Marek Polacek Committed by Marek Polacek

re PR middle-end/63879 (ICE compiling Linux Kernel fs/ext3/namei.c with -fsanitize=undefined)

	PR sanitizer/63879
	* fold-const.c (negate_expr_p) <case NEGATE_EXPR>: Return
	!TYPE_OVERFLOW_SANITIZED.
	(fold_negate_expr) <case INTEGER_CST>: Fold when overflow
	does not trap and when overflow wraps, or when SANITIZE_SI_OVERFLOW
	is 0.

	* c-c++-common/ubsan/pr63879-1.c: New test.
	* c-c++-common/ubsan/pr63879-2.c: New test.

From-SVN: r217766
parent 877088b7
2014-11-19 Marek Polacek <polacek@redhat.com>
PR sanitizer/63879
* fold-const.c (negate_expr_p) <case NEGATE_EXPR>: Return
!TYPE_OVERFLOW_SANITIZED.
(fold_negate_expr) <case INTEGER_CST>: Fold when overflow
does not trap and when overflow wraps, or when SANITIZE_SI_OVERFLOW
is 0.
2014-11-19 Ilya Tocar <ilya.tocar@intel.com>
* collect2.c (main): Don't call fatal_error before
......@@ -408,9 +408,11 @@ negate_expr_p (tree t)
&& TYPE_OVERFLOW_WRAPS (type));
case FIXED_CST:
case NEGATE_EXPR:
return true;
case NEGATE_EXPR:
return !TYPE_OVERFLOW_SANITIZED (type);
case REAL_CST:
/* We want to canonicalize to positive real constants. Pretend
that only negative ones can be easily negated. */
......@@ -555,7 +557,8 @@ fold_negate_expr (location_t loc, tree t)
tem = fold_negate_const (t, type);
if (TREE_OVERFLOW (tem) == TREE_OVERFLOW (t)
|| (!TYPE_OVERFLOW_TRAPS (type)
&& (flag_sanitize & SANITIZE_SI_OVERFLOW) == 0))
&& TYPE_OVERFLOW_WRAPS (type))
|| (flag_sanitize & SANITIZE_SI_OVERFLOW) == 0)
return tem;
break;
......
2014-11-19 Marek Polacek <polacek@redhat.com>
PR sanitizer/63879
* c-c++-common/ubsan/pr63879-1.c: New test.
* c-c++-common/ubsan/pr63879-2.c: New test.
2014-11-19 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/62167
......
/* PR sanitizer/63879 */
/* { dg-do compile } */
/* { dg-options "-fsanitize=undefined" } */
struct A
{
int inode;
} * a;
int b, c;
void
fn1 ()
{
int d = 0;
while (b)
{
if (a->inode)
d++;
a = 0;
}
c = d - 1;
for (; c >= 0; c--)
;
}
/* PR sanitizer/63879 */
/* { dg-do compile } */
/* { dg-options "-fsanitize=undefined" } */
int a;
void
fn1 ()
{
int b = 2;
for (; a;)
while (b >= 0)
b--;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment