Re: [patch, fortran] Fix Bug 100194 - [13/14/15/16 Regression] ICE in gfc_trans_create_temp_array...
Paul Richard Thomas <[email protected]>
| Newsgroups | gmane.comp.gcc.patches,gmane.comp.gcc.fortran |
|---|---|
| Message-ID | <CAGkQGi+gSfLE+QV6gcz7kg8-7fPqHgXhkuj9X+VS_352L+6gkA@mail.gmail.com> |
Hello Jerry and Christopher, The patch does as advertised on the box. However, the attached test fails with: pault@fedora:~/prs/pdt$ ~/gfc/bin/gfortran ~/prs/pr100194/p*.f90 -g -std=f2018 -fdump-tree-original ;./a.out s(x(1:4:2) => z = 252 0 s(u(1,:) => z = 5376 0 0 0 whereas the other brands give no output. Cheers Paul On Tue, 31 Mar 2026 at 20:30, Jerry D <[email protected]> wrote: > > The attached patch from Christopher. > > I adjusted the commit log a little bit and added the two previously provided > test cases from the PR, z2 and z3, which passed without the patch and still do. > > The patch itself is is simple. > > Regression tested on x86_64-linux. > > I plane to commit this later today. > > Regards, > > Jerry > > ---- > > commit 9d0f9b8f1a11a2e08786278e05ee5cbb77f5b7ff (HEAD -> master) > Author: Christopher Albert <[email protected]> > Date: Tue Mar 31 08:26:57 2026 +0200 > > fortran: Fix ICE in gfc_trans_create_temp_array for assumed-rank [PR100194] > > When a non-contiguous assumed-rank actual argument is passed to a > contiguous assumed-rank dummy, the compiler routes it through > gfc_conv_subref_array_arg which uses the scalarizer. The scalarizer > requires known rank at compile time, but assumed-rank arrays have > rank = -1, hitting gcc_assert (ss->dimen > 0). > > Skip the scalarizer path for assumed-rank expressions and let them > fall through to gfc_conv_array_parameter, which handles assumed-rank > via the runtime pack/unpack functions. > > gcc/fortran/ChangeLog: > > PR fortran/100194 > * trans-expr.cc (gfc_conv_procedure_call): Skip > gfc_conv_subref_array_arg for assumed-rank actual arguments > (e->rank == -1) when the dummy is contiguous. > > gcc/testsuite/ChangeLog: > > PR fortran/100194 > * gfortran.dg/pr100194.f90: New test. > > Signed-off-by: Christopher Albert <[email protected]>
pr100194.f90
(text/x-fortran, 1.1 KB)
subroutine s(x, res)
integer :: x(..)
integer, allocatable :: res(:)
select rank (x)
rank (1)
end select
call t(x)
contains
subroutine t(y)
integer, contiguous :: y(..)
select rank (y)
rank (1)
res = 2*y
end select
end
end
interface
subroutine s(x, res)
integer :: x(..)
integer, allocatable :: res(:)
end
end interface
type :: t
character(4) :: chr
integer :: r(2)
end type
integer :: x(4) = [42,84,126,168]
type(t) :: y = t('abcd', [42,84])
integer, allocatable :: z(:), u(:,:)
u = reshape ([x,4*x,16*x,64*x],[4,4])
call s(x, z)
if (any (z /= [84,168,252,336])) print *, 'Original bug => z = ', z
call s(x(1:4:2), z)
if (any (z /= [84,252])) print *, 's(x(1:4:2) => z = ', z
call s(x([1,3,4,2]), z)
if (any (z /= [84,252,336,168])) print *, 's(x([1,3,4,2]) => z = ', z
call s(y%r, z)
if (any (z /= [84,168])) print *, 's(y%r => z = ', z
call s(u(1,:), z)
if (any (z /= [84,336,1344,5376])) print *, 's(u(1,:) => z = ', z
call s(u(:,1), z)
if (any (z /= [84,168,252,336])) print *, 's(u(:,1) => z = ', z
end