[Bug fortran/64397] [OOP] Runtime segfault with parenthesis expression passed to polymorphic dummy argument

janus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Dec 23 22:27:00 GMT 2014


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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[OOP] Runtime segfault with |[OOP] Runtime segfault with
                   |type-bound assignment and   |parenthesis expression
                   |parenthesis                 |passed to polymorphic dummy
                   |                            |argument

--- Comment #4 from janus at gcc dot gnu.org ---
As shown by -fdump-tree-original, the first call to 'ass' is translated to:

  {
    struct __class_main_My_integer_t class.11;

    class.11._vptr = (struct __vtype_main_My_integer * {ref-all})
&__vtab_main_My_integer;
    class.11._data = (struct my_integer *) &a;
    ass (&class.11);
  }


The second call, however, is translated to:

  {
    void * restrict D.3514;
    integer(kind=8) D.3513;
    integer(kind=8) D.3512;
    integer(kind=8) D.3511;
    struct __class_main_My_integer_t D.3510;
    struct my_integer D.3509;
    struct __class_main_My_integer_t class.13;

    class.13._vptr = (struct __vtype_main_My_integer * {ref-all})
&__vtab_main_My_integer;
    D.3509 = a;
    class.13._data = (struct my_integer *) &D.3509;
    D.3510 = class.13;
    ass (&class.13);
    if ((void *) D.3510.x.data != 0B)
      {
        D.3511 = (D.3510.x.dim[0].ubound - D.3510.x.dim[0].lbound) + 1;
        D.3512 = NON_LVALUE_EXPR <D.3511>;
        D.3513 = D.3512 * 4;
        D.3514 = (void * restrict) __builtin_malloc (MAX_EXPR <(unsigned long)
D.3513, 1>);
        class.13.x.data = D.3514;
        __builtin_memcpy ((real(kind=4)[0:] * restrict) class.13.x.data,
(real(kind=4)[0:] * restrict) D.3510.x.data, (unsigned long) (D.3512 * 4));
      }
    else
      {
        class.13.x.data = 0B;
      }
    if (class.13._data->x.data != 0B)
      {
        __builtin_free ((void *) class.13._data->x.data);
      }
    class.13._data->x.data = 0B;
  }


While nothing is done after the call itself in the first case, quite a bit of
cleanup-code is added in the second case (which is also seen in comment 2.



More information about the Gcc-bugs mailing list