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

--- Comment #14 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to kargls from comment #13)
> (In reply to Paul Thomas from comment #12)
> > Created attachment 59753 [details]
> > Fix for this PR
> > 
> > Testcase. Regressions tests OK. Will submit when my tree is cleared of other
> > work.
> > 
> > ! { dg-do compile }
> > !
> > ! Fix ICEs caused by patch for PR78026
> > !
> > ! Contributed by Gerhard Steinmetz  <gs...@t-online.de>
> > !
> > module m
> > contains
> > ! z04, z06-z10 and z12-z16 were all variants, picked up by the errors below.
> >    subroutine z01
> >      select type (x%a)  ! { dg-error "nonderived-type variable" }
> >      end select         ! { dg-error "Expecting END SUBROUTINE" }
> >    end
> >    subroutine z02
> >      select type (x%    ! { dg-error "nonderived-type variable" }
> >      end select         ! { dg-error "Expecting END SUBROUTINE" }
> >    end
> >    subroutine z03
> >      select type (x%&    ! { dg-error "nonderived-type variable" }
> >      end select
> >    end
> >    subroutine z05
> >      select type (x(    ! { dg-error "Syntax error" }
> >      end select         ! { dg-error "Expecting END SUBROUTINE" }
> >    end
> >    subroutine z11
> >      select type (x[1]  ! { dg-error "not a coarray" }
> >      end select         ! { dg-error "Expecting END SUBROUTINE" }
> >    end
> > end module
> 
> If something goes wrong, do you possibly need to free expr1 and expr2.
> Elsewhere in gfc_match_select_type() one seems the the idiom
> 
>   if (...)
>    {
>      m = MATCH_ERROR;
>      goto cleanup;
>   }

Hi Steve,

I'm sorry to have taken so long to come back to you on this. Freeing expr1 and
expr2 is precisely the problem. They are so badly screwed up that they are
causing the segfault. I took the view that it is better to have dangling memory
than the ICE.

Paul

Reply via email to