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

--- Comment #3 from janus at gcc dot gnu.org ---
-fdump-tree-original shows the following dump of the copy function (with
gfortran 4.8):


copy (integer(kind=4) & restrict a, struct __class__STAR & restrict b)
{
  {
    integer(kind=4) * __tmp_INTEGER_4;

    (void) __builtin_memcpy (b->_data, (void *) b->_vptr->_def_init, (unsigned
long) b->_vptr->_size);
    switch (b->_vptr->_hash)
      {
        case 177599:;
        __tmp_INTEGER_4 = (integer(kind=4) *) b->_data;
        *__tmp_INTEGER_4 = *a;
        L.5:;
        goto L.3;
      }
    L.3:;
    L.2:;
    L.1:;
  }
}


With 4.9 and trunk additional code is initialized for calling a finalizer, but
since the failure occurs already with 4.8, the problem must be in here already.

Now, the error goes away if one removes the INTENT(OUT). The only thing that
changes in the dump is that the __builtin_memcpy call is removed, which means
that this line must be the cuplrit.

After staring at it for a while, I concluded that the call to __builtin_memcpy
itself looks fine. The problem is that the _def_init component is NULL in the
case at hand (which can be seen the full dump, not shown here).

So I guess all were missing is a line like

if (b->_vptr->_def_init != NULL)

before the __builtin_memcpy.

Reply via email to