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

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenther at suse dot de

--- Comment #18 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Uroš Bizjak from comment #17)
> (In reply to Mat Cross from comment #14)
> > For the record, perhaps it is of interest for me to note that we are running
> > into this (cf. PR64230 comment 9) on code like
> > 
> > Program test
> >   Implicit None
> >   Type :: t1
> >     Integer, Allocatable :: i
> >   End Type
> >   Type :: t2
> >     Integer, Allocatable :: i
> >   End Type
> >   Type, Extends (t1) :: t3
> >     Type (t2) :: j
> >   End Type
> >   Type, Extends (t3) :: t4
> >     Integer, Allocatable :: k
> >   End Type
> >   Call s
> >   Print *, 'ok'
> > Contains
> >   Subroutine s
> >     Class (t1), Allocatable :: x
> >     Allocate (t4 :: x)
> >   End Subroutine
> > End Program
> > 
> > Since the crash is in bad compiler-generated finalization code (since 4.9),
> > and given that (if I recall correctly) gfortran is using the Fortran 2008
> > semantics for entities declared in a main program being implicitly saved,
> > this is why removing the Deallocate (in the comment 12 example) works - the
> > finalizer is never called then.
> 
> No wonder this test crashes. Tree-optimizers (-O2) on x86_64 produce:

[...]

I was able to trace dumps down to _.fre2 tree dump, where we have:

  <bb 12>:
  # idx_104 = PHI <0(11), idx_122(16)>
  offset_115 = 0;
  ptr2_119 = (struct t3 *) offset_115;
  _120 = &ptr2_119->j;

This can't be right, we have a dereference from zero. If the frontend produced
correct code, then tree-optimization passes made a mess here.

CC Richi.

Reply via email to