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

--- Comment #2 from Kirill Chilikin <chilikin.k at gmail dot com> ---
Some additional information:

$ gfortran -g -o test test.f90 -fdump-tree-original
$ cat test.f90.005t.original | head -n 747 | tail -n 26
  {
    struct t3 zero.25;
    struct array00_t3 desc.26;
    struct t3 D.4638;

    desc.26.dtype = {.elem_len=80, .rank=0, .type=5};
    desc.26.data = (void * restrict) &zero.25;
    desc.26.span = (integer(kind=8)) desc.26.dtype.elem_len;
    {
      struct array00_t3 desc.27;

      desc.27.dtype = {.elem_len=80, .rank=0, .type=5};
      desc.27.data = (void * restrict) &x3;
      desc.27.span = (integer(kind=8)) desc.27.dtype.elem_len;
      __final_test_module_T1 (&desc.27, 80, 0);
    } 
    D.4638 = x3;
    x3 = (struct t3) t3_constructor ();
    if ((struct t1_pointer[0:] * restrict) D.4638.t1.next._data.data != 0B)
      {
        __builtin_free ((void *) D.4638.t1.next._data.data);
        (struct t1_pointer[0:] * restrict) D.4638.t1.next._data.data = 0B;
      }
    D.4638.t1.next._vptr = (struct __vtype_test_module_T1_pointer * {ref-all})
&__vtab_test_module_T1_pointer;
    __vtab_test_module_T3._final (&desc.26, __vtab_test_module_T3._size, 0);
  }

The call of __vtab_test_module_T3._final is on desc.26 pointing to otherwise
unused zero.25.

$ gdb ./test
(gdb) b 102
Breakpoint 1 at 0x4033ca: file test.f90, line 102.
(gdb) r
Breakpoint 1, test_program () at test.f90:102
102       X3 = T3()
(gdb) p x2
$1 = ( t1 = ( n_next = 1, next = ( _data = (( t1 = ( _data = 0x4062a0 <x1>,
_vptr = 0x406140 <__test_module_MOD___vtab_test_module_T1> ) )), _vptr =
0x4061a0 <__test_module_MOD___vtab_test_module_T1_pointer> ) ), x =
1.40129846e-45 )
(gdb) b t1_destructor
Breakpoint 2 at 0x4027f0: file test.f90, line 49.
(gdb) ignore 2 3
Will ignore next 3 crossings of breakpoint 2.
(gdb) c
Breakpoint 2, test_module::t1_destructor (self=...) at test.f90:49
49          IF (ALLOCATED(SELF%NEXT)) THEN
(gdb) backtrace
#0  test_module::t1_destructor (self=...) at test.f90:49
#1  0x0000000000401813 in test_module::__final_test_module_T1 (array=...,
    byte_stride=80, fini_coarray=.FALSE.) at test.f90:90
#2  0x00000000004035d0 in test_program () at test.f90:102
(gdb) p self
$2 = ( n_next = 1, next = ( _data = (( t1 = ( _data = 0x4062a0 <x1>, _vptr =
0x406140 <__test_module_MOD___vtab_test_module_T1> ) )), _vptr = 0x4061a0
<__test_module_MOD___vtab_test_module_T1_pointer> ) )

But in the compiled program, it seems to finalize X2%T1.

Reply via email to