https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67933
--- Comment #4 from Mikael Morin <mikael at gcc dot gnu.org> --- (In reply to Paul Thomas from comment #3) > (In reply to Mikael Morin from comment #2) > > The generated finalization wrapper has code doing > > deallocate(ptr2%classes(:)%class_var) > > where ptr2 is a pointer of type list_t to be finalized. > > This is missing scalarization, a correct code would do instead: > > do i=1,size(ptr2) This should use size(ptr2%classes) instead. > > ptr3 => ptr2%classes(i) > > deallocate (ptr3%class_var) > > end do > > Hi Mikael, > > This does not seem to be the problem. It is actually the > gfc_reset_vptr (&se.pre, al->expr); > at trans-stmt.c:6048. > The problem is indeed in gfc_reset_vptr. It is trying to do lhs%_vptr => &vtab The lhs is ptr2%classes(:)%class_var (as I said above) which has nonzero rank, so the code is expecting an array descriptor assignment, which the rhs isn't. > Once gfc_reset_vptr is modified to quit if it doesn't find a vptr, > compilation succeeds and the finalizer has: > Uh, I didn't expect scalarization to work with the rest of the code either; good this should make the problem easier to fix.