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

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
I have reproduced the warning in comment #0 with a powerpc64le-linux and
sparcv9-sun-solaris2.11 (but on x86_64-linux).  Based on the dumps the warning
seems justified.  Here's what I see in elemental_subroutine_3.f90.004t.gimple
for the second call to memcpy (the one that triggers the warning):

test ()
  ...
  static struct mytype x[6] = {{.x=1}, {.x=20}, {.x=300}, {.x=4000},
{.x=50000}, {.x=1000000}};
  ...
            parm.11.data = &x[3];
  ...
                _15 = parm.11.data;
              __builtin_memcpy (data.13, _15, 16);

I.e., memcpy is being called to copy 16 bytes from the six-element array x,
starting at element 4.  With each element being 4 bytes wide, the last three
elements of x are only 12 bytes in size.  This doesn't significantly change in
any of the subsequent dumps and the warning seems to be faithfully reporting
the same numbers: a read of 16 bytes from a region of size 12.

The reason the warning doesn't show up on x86_64 is because there GCC doesn't
emit memcpy to copy the elements.  Instead it uses a MEM_REF.

Reply via email to