I can't believe that this isn't a duplicate although I can't find it. The following code gives an ICE for me on gfortran 7.2, if the line mine=getchars(2,4) is included: module m implicit none contains function getchars(my_len,my_size) integer, intent(in) :: my_len, my_size character(my_len) :: getchars(my_size) getchars = 'A-' end function getchars end module m program testca use m, only: getchars implicit none character(:), allocatable :: mine(:) ! this works: write(*,*) getchars(2,4) write(*,*) len(getchars(2,4)) write(*,*) size(getchars(2,4)) ! this works: mine = [character(2) :: 'A-','A-'] write(*,*) mine ! ICE occurs if this line is included: mine = getchars(2,4) end program testca WB
Confirmed from 4.8 up to trunk (8.0). Note that if the compiler is configured with --enable-checking=yes, I get pr82923.f90:11:0: program testca Error: Local declaration from a different function ..__result pr82923.f90:27:0: mine = getchars(2,4) note: in statement .mine = ..__result; pr82923.f90:11:0: program testca Error: Local declaration from a different function ..__result pr82923.f90:27:0: mine = getchars(2,4) note: in statement _101 = (integer(kind=8)) ..__result; pr82923.f90:11:0: program testca Error: Local declaration from a different function ..__result pr82923.f90:27:0: mine = getchars(2,4) note: in statement D.3753 = (sizetype) ..__result; during GIMPLE pass: cfg pr82923.f90:11:0: program testca internal compiler error: verify_gimple failed instead of during RTL pass: expand pr82923.f90:27:0: mine = getchars(2,4) internal compiler error: in expand_expr_real_1, at expr.c:9865 for 5.5.0 to 8.0 and pr82923.f90:27:0: internal compiler error: in gimplify_var_or_parm_decl, at gimplify.c:1741 mine = getchars(2,4) ^ for 4.8 and 4.9. No duplicate in store.
Ha! That's an 'amusing' one. I too am surprised that there is no duplicate. I'll take it. Paul
Created attachment 42637 [details] Fix for the bug This one does the job and it regtests OK. However, I'll wait until I get PR78990 out of the way before submitting. Paul
> Created attachment 42637 [details] > Fix for the bug > > This one does the job and it regtests OK. Confirmed, however I see an ICE when compiling the "type" variant of pr65381.
> Confirmed, however I see an ICE when compiling the "type" variant of pr65381. I have forgotten to say that the ICE is similar to the one in comment 1 pr65381_red.f90:15:0: pure function fixedStringTable(this) result(fixed) Error: Local declaration from a different function D.3828 pr65381_red.f90:15:0: pure function fixedStringTable(this) result(fixed) note: in statement D.3828 = MAX_EXPR <_8, 0>; pr65381_red.f90:15:0: pure function fixedStringTable(this) result(fixed) Error: Local declaration from a different function D.3828 pr65381_red.f90:15:0: pure function fixedStringTable(this) result(fixed) note: in statement _11 = (sizetype) D.3828; pr65381_red.f90:15:0: pure function fixedStringTable(this) result(fixed) Error: Local declaration from a different function D.3828 pr65381_red.f90:15:0: pure function fixedStringTable(this) result(fixed) note: in statement D.3894 = (sizetype) D.3828; pr65381_red.f90:15:0: pure function fixedStringTable(this) result(fixed) Error: Local declaration from a different function D.3828 pr65381_red.f90:26:0: fixed(k) = this(i)%list(j)%chars note: in statement D.3883 = D.3828; during GIMPLE pass: cfg pr65381_red.f90:15:0: pure function fixedStringTable(this) result(fixed) internal compiler error: verify_gimple failed
> I can't believe that this isn't a duplicate although I can't find it. ... PRs 66694 and 82617 are "fixed" by the patch at https://gcc.gnu.org/ml/fortran/2018-05/msg00046.html.
Author: pault Date: Sat May 19 10:49:50 2018 New Revision: 260392 URL: https://gcc.gnu.org/viewcvs?rev=260392&root=gcc&view=rev Log: 2018-05-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/82923 PR fortran/66694 PR fortran/82617 * trans-array.c (gfc_alloc_allocatable_for_assignment): Set the charlen backend_decl of the rhs expr to ss->info->string_length so that the value in the current scope is used. 2018-05-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/82923 * gfortran.dg/allocate_assumed_charlen_4.f90: New test. Note that the patch fixes PR66694 & PR82617, although the testcases are not explicitly included. Added: trunk/gcc/testsuite/gfortran.dg/allocate_assumed_charlen_4.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-array.c trunk/gcc/testsuite/ChangeLog
Author: pault Date: Sat May 19 11:32:30 2018 New Revision: 260395 URL: https://gcc.gnu.org/viewcvs?rev=260395&root=gcc&view=rev Log: 2018-05-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/82923 PR fortran/66694 PR fortran/82617 * trans-array.c (gfc_alloc_allocatable_for_assignment): Set the charlen backend_decl of the rhs expr to ss->info->string_length so that the value in the current scope is used. 2018-05-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/82923 * gfortran.dg/allocate_assumed_charlen_4.f90: New test. Note that the patch fixes PR66694 & PR82617, although the testcases are not explicitly included. Added: branches/gcc-8-branch/gcc/testsuite/gfortran.dg/allocate_assumed_charlen_4.f90 Modified: branches/gcc-8-branch/gcc/fortran/ChangeLog branches/gcc-8-branch/gcc/fortran/trans-array.c branches/gcc-8-branch/gcc/testsuite/ChangeLog
Author: pault Date: Sat May 19 14:53:58 2018 New Revision: 260399 URL: https://gcc.gnu.org/viewcvs?rev=260399&root=gcc&view=rev Log: 2018-05-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/82923 PR fortran/66694 PR fortran/82617 * trans-array.c (gfc_alloc_allocatable_for_assignment): Set the charlen backend_decl of the rhs expr to ss->info->string_length so that the value in the current scope is used. 2018-05-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/82923 * gfortran.dg/allocate_assumed_charlen_4.f90: New test. Note that the patch fixes PR66694 & PR82617, although the testcases are not explicitly included. Added: branches/gcc-7-branch/gcc/testsuite/gfortran.dg/allocate_assumed_charlen_4.f90 Modified: branches/gcc-7-branch/gcc/fortran/ChangeLog branches/gcc-7-branch/gcc/fortran/trans-array.c branches/gcc-7-branch/gcc/testsuite/ChangeLog
Fixed on 7-branch through to trunk. Thanks for the report and sorry that it took so long. Paul
I suppose that I have to mark it as resolved :-)
Author: pault Date: Sun May 20 09:59:54 2018 New Revision: 260413 URL: https://gcc.gnu.org/viewcvs?rev=260413&root=gcc&view=rev Log: 2018-05-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/82923 PR fortran/66694 PR fortran/82617 * trans-array.c (gfc_alloc_allocatable_for_assignment): Set the charlen backend_decl of the rhs expr to ss->info->string_length so that the value in the current scope is used. 2018-05-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/82923 * gfortran.dg/allocate_assumed_charlen_4.f90: New test. Note that the patch fixes PR66694 & PR82617, although the testcases are not explicitly included. Added: trunk/gcc/testsuite/gfortran.dg/select_type_42.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/match.c trunk/gcc/testsuite/ChangeLog
> > Added: > trunk/gcc/testsuite/gfortran.dg/select_type_42.f90 > Modified: > trunk/gcc/fortran/ChangeLog > trunk/gcc/fortran/match.c > trunk/gcc/testsuite/ChangeLog Sorry, this last was the patch for PR80657 Paul.