tree-ssa-structalias.c (get_constraint_for_ptr_offset): Multiply in UWHI to avoid...
authorJakub Jelinek <jakub@redhat.com>
Mon, 19 Jun 2017 17:56:44 +0000 (19:56 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 19 Jun 2017 17:56:44 +0000 (19:56 +0200)
* tree-ssa-structalias.c (get_constraint_for_ptr_offset): Multiply
in UWHI to avoid undefined overflow.

From-SVN: r249381

gcc/ChangeLog
gcc/tree-ssa-structalias.c

index 396f112816b2c8ff855c141f50ea49884d3f78dc..268abf336562adb3baf2e1e1458a5dfcec9aa476 100644 (file)
@@ -1,5 +1,8 @@
 2017-06-19  Jakub Jelinek  <jakub@redhat.com>
 
+       * 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
index a4abd28c57ac06f1dee49263e881343bdd1a86c7..e563e9dee72b8bb0257eaaddfeb8a406b8c966c2 100644 (file)
@@ -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;
        }