On 12/16/19 3:44 PM, Jakub Jelinek wrote:
On Mon, Dec 16, 2019 at 03:28:29PM -0700, Martin Sebor wrote:
PR middle-end/92952 - gfortran.dg/lto/pr87689 FAILs

gcc/ChangeLog:

        PR middle-end/92952
        * builtins.c (compute_objsize): Adjust offset by the array low bound.

Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c      (revision 279443)
+++ gcc/builtins.c      (working copy)
@@ -3999,6 +3999,16 @@ compute_objsize (tree dest, int ostype, tree *pdec
             above.  */
          if (TREE_CODE (dest) == ARRAY_REF)
            {
+             tree lowbnd = array_ref_low_bound (dest);
+             if (!integer_zerop (lowbnd) && tree_fits_uhwi_p (lowbnd))
+               {
+                 /* Adjust the offset by the low bound of the array
+                    domain (normally zero but 1 in Fortran).  */
+                 unsigned HOST_WIDE_INT lb = tree_to_uhwi (lowbnd);
+                 offrng[0] -= lb;
+                 offrng[1] -= lb;
+               }

I don't understand why uhwi is used.  offrng is an array of wide_int with
precision of sizetype, so why not instead:
              if (!integer_zerop (lowbnd) && TREE_CODE (lowbnd) == INTEGER_CST)
                {
                  /* Adjust the offset by the low bound of the array
                     domain (normally zero but 1 in Fortran).  */
                  wide_int lb = wi::to_wide (lowbnd, sizprec);
                  offrng[0] -= lb;
                  offrng[1] -= lb;
                }
?

I don't see what difference it makes.  They should both do the same
thing.  If you just prefer your alternative, feel free to change it.

Martin

Reply via email to