[Bug fortran/106731] ICE on automatic array of derived type with DTIO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 Jerry DeLisle changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #15 from Jerry DeLisle --- Backport complete, closing.
[Bug fortran/106731] ICE on automatic array of derived type with DTIO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 --- Comment #14 from CVS Commits --- The releases/gcc-12 branch has been updated by Jerry DeLisle : https://gcc.gnu.org/g:6d307fda2b9ba71fe18f1449f7444bed7ff05193 commit r12-9055-g6d307fda2b9ba71fe18f1449f7444bed7ff05193 Author: Jerry DeLisle Date: Sat Jan 21 14:58:05 2023 -0800 Backported from master: PR fortran/106731 gcc/fortran/ChangeLog: * trans-array.cc (gfc_trans_auto_array_allocation): Remove gcc_assert (!TREE_STATIC()). gcc/testsuite/ChangeLog: * gfortran.dg/pr106731.f90: New test.
[Bug fortran/106731] ICE on automatic array of derived type with DTIO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 --- Comment #13 from Jerry DeLisle --- I will backport to 12 as it is an ice on Valid.
[Bug fortran/106731] ICE on automatic array of derived type with DTIO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 anlauf at gcc dot gnu.org changed: What|Removed |Added Status|NEW |ASSIGNED --- Comment #12 from anlauf at gcc dot gnu.org --- Fixed on mainline for gcc-13. Jerry, are you planning to backport? Otherwise please close the PR.
[Bug fortran/106731] ICE on automatic array of derived type with DTIO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 --- Comment #11 from federico --- Thank you. I can confirm the patch works. I thought that, while fixing the issue, removing the assert was not the best solution as automatic arrays are not supposed to be static. My bad. Happy holidays, Federico
[Bug fortran/106731] ICE on automatic array of derived type with DTIO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 --- Comment #10 from CVS Commits --- The master branch has been updated by Jerry DeLisle : https://gcc.gnu.org/g:7e76cd96950f49ce21246d44780e972d86b2bcdd commit r13-4862-g7e76cd96950f49ce21246d44780e972d86b2bcdd Author: Steve Kargl Date: Thu Dec 22 20:38:57 2022 -0800 Remove not needed assert macro which fails. PR fortran/106731 gcc/fortran/ChangeLog: * trans-array.cc (gfc_trans_auto_array_allocation): Remove gcc_assert (!TREE_STATIC()). gcc/testsuite/ChangeLog: * gfortran.dg/pr106731.f90: New test.
[Bug fortran/106731] ICE on automatic array of derived type with DTIO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 --- Comment #9 from Jerry DeLisle --- (In reply to Jerry DeLisle from comment #8) > The simple patch does indeed fix the ICE at compile time. It also > regression tests cleanly. > > I am studying the results of running this test case to be sure it makes > sense. The DTIO procedure in the example is not getting invoked from my > first look. Indeed it was not being invoked since the line: print *, 'n=',n,automatic(n)%x Completely resolves the value of x. If instead one uses: print *, 'n=',n,automatic The DTIO procedure is invoked as expected. I will commit this one under simple and obvious rule shortly with a test case.
[Bug fortran/106731] ICE on automatic array of derived type with DTIO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 Jerry DeLisle changed: What|Removed |Added CC||jvdelisle at gcc dot gnu.org --- Comment #8 from Jerry DeLisle --- The simple patch does indeed fix the ICE at compile time. It also regression tests cleanly. I am studying the results of running this test case to be sure it makes sense. The DTIO procedure in the example is not getting invoked from my first look.
[Bug fortran/106731] ICE on automatic array of derived type with DTIO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 anlauf at gcc dot gnu.org changed: What|Removed |Added Keywords||ice-on-valid-code --- Comment #7 from anlauf at gcc dot gnu.org --- (In reply to federico from comment #4) > The TREE_STATIC assert should be valid according to what reported in the > implementation at report https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48298 > > But, I can't tell what that means. I did a "git blame" on gcc/fortran/trans-array.cc, and that says that the last change of the offentding line was in 2004. The corresponding commit replaced assert() by gcc_assert(). Haven't looked further, but I guess you should really try Steve's patch and see if it not only fixes your problem, but regtests ok and maybe works for cases not yet in the testsuite.
[Bug fortran/106731] ICE on automatic array of derived type with DTIO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 --- Comment #6 from federico --- Yeah this popped up playing with DTIO, this feature is not widely used apparently. I'll also try to get a copy of the gcc source code and build pipeline to see if I can help.
[Bug fortran/106731] ICE on automatic array of derived type with DTIO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 --- Comment #5 from Steve Kargl --- On Wed, Aug 24, 2022 at 07:10:20PM +, federico.perini at gmail dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 > > --- Comment #4 from federico --- > The TREE_STATIC assert should be valid according to what reported in the > implementation at report https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48298 > > But, I can't tell what that means. > I can only report what I find. If the gcc_assert() is commented out your code compiles and executes. Whether the output is correct or not, I don't know as I don't use DTIO. I guess someone else will need to fire up gdb and debug this problem for you.
[Bug fortran/106731] ICE on automatic array of derived type with DTIO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 --- Comment #4 from federico --- The TREE_STATIC assert should be valid according to what reported in the implementation at report https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48298 But, I can't tell what that means.
[Bug fortran/106731] ICE on automatic array of derived type with DTIO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 kargl at gcc dot gnu.org changed: What|Removed |Added CC||kargl at gcc dot gnu.org --- Comment #3 from kargl at gcc dot gnu.org --- (In reply to federico from comment #0) > A derived type that has user-defined I/O causes ICE on all gfortran versions > 7 to 12.1.0, whenever it's being used as an automatic object. > > The error is at > > >63 | type(t) :: automatic(n) > | 1 > internal compiler error: in gfc_trans_auto_array_allocation, at > fortran/trans-array.cc:6617 > > This does not happen if the derived type is allocated. > > Here's the simplest example: > > module causes_ice > implicit none > > type :: t > real(8) :: x > contains > procedure, private :: write_formatted > generic :: write(formatted) => write_formatted > end type t > > contains > > subroutine write_formatted(this, unit, iotype, v_list, iostat, iomsg) >class(t), intent(in) :: this >integer, intent(in) :: unit >character(*), intent(in) :: iotype >integer, intent(in) :: v_list(:) >integer, intent(out) :: iostat >character(*), intent(inout) :: iomsg >write(unit, '(a)', iostat=iostat, iomsg=iomsg) 'dummy' > end subroutine write_formatted > > end module causes_ice > > module use_t > use causes_ice > implicit none > > public :: automatic_alloc > > contains > > subroutine automatic_alloc(n) > integer, intent(in) :: n > > ! Automatic array: ICE! > type(t) :: automatic(n) > > ! Allocatable: works > type(t), allocatable :: alloc(:) > allocate(alloc(n)) > > ! Do anything > print *, 'n=',n,automatic(n)%x > > end subroutine automatic_alloc > > end module use_t > > program test > use use_t > call automatic_alloc(1) > end program test > > I could find other DTIO-related bugs, but none seemed related with the > allocation type. You're hitting an assert() in trans-array.cc. It's unclear to me why the assert() is there. If it is commented out, the code compiles and executes. % git diff gcc/fortran/trans-array.cc | cat diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 05134952db4..c5916aeee53 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -6614,7 +6614,7 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym, type = TREE_TYPE (type); gcc_assert (!sym->attr.use_assoc); - gcc_assert (!TREE_STATIC (decl)); +// gcc_assert (!TREE_STATIC (decl)); gcc_assert (!sym->module); if (sym->ts.type == BT_CHARACTER
[Bug fortran/106731] ICE on automatic array of derived type with DTIO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 --- Comment #2 from federico --- For the sake of completeness, fixed-size does not cause an ICE: type(t) :: fixed(5) ! works
[Bug fortran/106731] ICE on automatic array of derived type with DTIO
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731 Martin Liška changed: What|Removed |Added CC||marxin at gcc dot gnu.org, ||pault at gcc dot gnu.org Ever confirmed|0 |1 Last reconfirmed||2022-08-24 Status|UNCONFIRMED |NEW --- Comment #1 from Martin Liška --- Likely started with r7-2882-ge73d3ca6d1caf9c1.