From c9f8853f9e74816ccb68a5a549f1f61295ce07ed Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 19 Jun 2017 19:56:44 +0200 Subject: [PATCH] tree-ssa-structalias.c (get_constraint_for_ptr_offset): Multiply in UWHI to avoid undefined overflow. * tree-ssa-structalias.c (get_constraint_for_ptr_offset): Multiply in UWHI to avoid undefined overflow. From-SVN: r249381 --- gcc/ChangeLog | 3 +++ gcc/tree-ssa-structalias.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 396f112816b..268abf33656 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,8 @@ 2017-06-19 Jakub Jelinek + * tree-ssa-structalias.c (get_constraint_for_ptr_offset): Multiply + in UWHI to avoid undefined overflow. + PR sanitizer/81125 * ubsan.h (enum ubsan_encode_value_phase): New. (ubsan_encode_value): Change second argument to diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index a4abd28c57a..e563e9dee72 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -3087,7 +3087,7 @@ get_constraint_for_ptr_offset (tree ptr, tree offset, { /* Make sure the bit-offset also fits. */ HOST_WIDE_INT rhsunitoffset = soffset.to_shwi (); - rhsoffset = rhsunitoffset * BITS_PER_UNIT; + rhsoffset = rhsunitoffset * (unsigned HOST_WIDE_INT) BITS_PER_UNIT; if (rhsunitoffset != rhsoffset / BITS_PER_UNIT) rhsoffset = UNKNOWN_OFFSET; } -- 2.30.2