]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/90213 (UBSAN: signed integer overflow: -5621332293356458048...
authorRichard Biener <rguenther@suse.de>
Thu, 25 Apr 2019 11:17:49 +0000 (11:17 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 25 Apr 2019 11:17:49 +0000 (11:17 +0000)
2019-04-24  Richard Biener  <rguenther@suse.de>

PR middle-end/90213
* gimple-fold.c (fold_const_aggregate_ref_1): Do multiplication
by size and BITS_PER_UNIT on poly-wide-ints.

From-SVN: r270570

gcc/ChangeLog
gcc/gimple-fold.c

index 2aeafe1d30c3a275ed7ab45581089da96fdbcd56..ce8281f0504795c1af7753f61a12c9ce78a08016 100644 (file)
@@ -1,3 +1,9 @@
+2019-04-24  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/90213
+       * gimple-fold.c (fold_const_aggregate_ref_1): Do multiplication
+       by size and BITS_PER_UNIT on poly-wide-ints.
+
 2019-04-25  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/90194
index a9afc4b392f52e179c005cf99bb8d09e1619016c..f30818042ee24531b82eb38d23fd4b1eba431d2c 100644 (file)
@@ -6983,14 +6983,10 @@ fold_const_aggregate_ref_1 (tree t, tree (*valueize) (tree))
                = wi::sext (wi::to_poly_offset (idx)
                            - wi::to_poly_offset (low_bound),
                            TYPE_PRECISION (TREE_TYPE (idx)));
-
+             woffset *= tree_to_uhwi (unit_size);
+             woffset *= BITS_PER_UNIT;
              if (woffset.to_shwi (&offset))
                {
-                 /* TODO: This code seems wrong, multiply then check
-                    to see if it fits.  */
-                 offset *= tree_to_uhwi (unit_size);
-                 offset *= BITS_PER_UNIT;
-
                  base = TREE_OPERAND (t, 0);
                  ctor = get_base_constructor (base, &offset, valueize);
                  /* Empty constructor.  Always fold to 0.  */