https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66578

--- Comment #4 from vehre at gcc dot gnu.org ---
Further analysis showed that while the offset of source's temporary descriptor
parm.3 is not as expected:

// allocate(c, source=a(:))
//       lb, ub,    , offset, data
parm.3 = {1, ub(a)+1,      0, &a[0]} // offset should be -1, when lb is set to
1.

c is initialized like this:

c = { parm.3.lb, parm.3.ub, -parm.3.lb, malloc( ((parm.3.ub - parm.3.lb) + 1) *
sizeof(int)) }

the loop to copy the data from "a", aka "parm.3.data", is this (simplified to
show the mistake more clearly):

for (i= 0; i <= c.ub; ++i)
  c.data[i + c.lb + c.offset] = parm.3.data[i + parm.3.offset]

The issue is that the loop is iterating over c.ub + 1 elements. It should
either be starting at 1 or stop at i < c.ub. Unfortunately is this computed by
the scalarizer, which I just don't understand. I assume, that having the offset
of parm.3 set correctly and the from setting of the loop to be 1 should resolve
the issue reliably. 

Any thoughts?

Reply via email to