[Bug fortran/113845] ice in gfc_get_array_ss
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113845 --- Comment #6 from anlauf at gcc dot gnu.org --- (In reply to Steve Kargl from comment #5) > I'm wondering if we need to worry about other actual > arguments. I note > > subroutine test_adjustl(x) > character(*) :: x(100) >x = adjustl(x) > call bar(x) > end subroutine > > does not cause problems. Playing around with variants, the common cause of the ICE seems: 1) assumed-length character dummy with rank > 0 e.g. these declarations fail too: character(*) :: x(*) character(*), allocatable :: x(:) but not: character(:), allocatable :: x(:) 2) any reference that is not a substring e.g. call bar(adjustl(x)) call bar(adjustl(x(1:1))) call bar(adjustl(x(:))) call bar(adjustl(x(:)(:))) but not call bar(adjustl(x(:)(1:len(x ! <- this is OK Quite obviously the attached patch is only a band-aid to prevent the infinite recursion, not a real solution...
[Bug fortran/113845] ice in gfc_get_array_ss
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113845 --- Comment #5 from Steve Kargl --- On Fri, Feb 09, 2024 at 10:06:47PM +, anlauf at gcc dot gnu.org wrote: > > --- Comment #4 from anlauf at gcc dot gnu.org --- > Created attachment 57374 > --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57374&action=edit > Proof-of-concept patch > > The attached - hackish - patch tries to avoid the infinite recursion by > fixing up the character length especially for the intrinsics ADJUST[LR]. > > I'm not entirely happy with this, but could not yet find a better place. > And in gfc_resolve_adjustl the backend_decl is not yet set. > You're much quicker than I! I only just identified the infinite recursion and where it was occurring in the scalarizer. I got sidetrack on a whole different issue. I'm wondering if we need to worry about other actual arguments. I note subroutine test_adjustl(x) character(*) :: x(100) x = adjustl(x) call bar(x) end subroutine does not cause problems.
[Bug fortran/113845] ice in gfc_get_array_ss
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113845 anlauf at gcc dot gnu.org changed: What|Removed |Added CC||anlauf at gcc dot gnu.org --- Comment #4 from anlauf at gcc dot gnu.org --- Created attachment 57374 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57374&action=edit Proof-of-concept patch The attached - hackish - patch tries to avoid the infinite recursion by fixing up the character length especially for the intrinsics ADJUST[LR]. I'm not entirely happy with this, but could not yet find a better place. And in gfc_resolve_adjustl the backend_decl is not yet set. Suggestions welcome!
[Bug fortran/113845] ice in gfc_get_array_ss
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113845 --- Comment #3 from kargl at gcc dot gnu.org --- (In reply to kargl from comment #2) > (In reply to kargl from comment #1) > > Thanks. Reduce test case. > > > > subroutine test_adjustl(x) > > character(*) :: x(100) > > call bar(adjustl(x)) > > end subroutine > > Forcing gfc_simplify_adjustl to return NULL fixes this issue. > Likely, simplification trashes the stack because ubound is > unknown. Whoops, after compiling I ran the wrong test code through gfortran. This appears to be a red-herring. :(
[Bug fortran/113845] ice in gfc_get_array_ss
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113845 --- Comment #2 from kargl at gcc dot gnu.org --- (In reply to kargl from comment #1) > Thanks. Reduce test case. > > subroutine test_adjustl(x) > character(*) :: x(100) > call bar(adjustl(x)) > end subroutine Forcing gfc_simplify_adjustl to return NULL fixes this issue. Likely, simplification trashes the stack because ubound is unknown.
[Bug fortran/113845] ice in gfc_get_array_ss
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113845 kargl at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2024-02-09 Ever confirmed|0 |1 CC||kargl at gcc dot gnu.org --- Comment #1 from kargl at gcc dot gnu.org --- Thanks. Reduce test case. subroutine test_adjustl(x) character(*) :: x(100) call bar(adjustl(x)) end subroutine subroutine test_adjustr(x) character(*) :: x(100) call bar(adjustr(x)) end subroutine On FreeBSD either subroutine causes % gfcx -c rt.f90 pid 50109 comm f951 has trashed its stack, killing gfortran: internal compiler error: Illegal instruction signal terminated program f951 Please submit a full bug report, with preprocessed source (by using -freport-bug Note, I have % limits | grep stack stacksize 524288 kB