* [Bug fortran/106731] ICE on automatic array of derived type with DTIO
2022-08-24 7:44 [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO federico.perini at gmail dot com
@ 2022-08-24 7:49 ` marxin at gcc dot gnu.org
2022-08-24 8:22 ` federico.perini at gmail dot com
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-08-24 7:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731
Martin Liška <marxin at gcc dot gnu.org> 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 <marxin at gcc dot gnu.org> ---
Likely started with r7-2882-ge73d3ca6d1caf9c1.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug fortran/106731] ICE on automatic array of derived type with DTIO
2022-08-24 7:44 [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO federico.perini at gmail dot com
2022-08-24 7:49 ` [Bug fortran/106731] " marxin at gcc dot gnu.org
@ 2022-08-24 8:22 ` federico.perini at gmail dot com
2022-08-24 17:38 ` kargl at gcc dot gnu.org
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: federico.perini at gmail dot com @ 2022-08-24 8:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731
--- Comment #2 from federico <federico.perini at gmail dot com> ---
For the sake of completeness, fixed-size does not cause an ICE:
type(t) :: fixed(5) ! works
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug fortran/106731] ICE on automatic array of derived type with DTIO
2022-08-24 7:44 [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO federico.perini at gmail dot com
2022-08-24 7:49 ` [Bug fortran/106731] " marxin at gcc dot gnu.org
2022-08-24 8:22 ` federico.perini at gmail dot com
@ 2022-08-24 17:38 ` kargl at gcc dot gnu.org
2022-08-24 19:10 ` federico.perini at gmail dot com
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: kargl at gcc dot gnu.org @ 2022-08-24 17:38 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug fortran/106731] ICE on automatic array of derived type with DTIO
2022-08-24 7:44 [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO federico.perini at gmail dot com
` (2 preceding siblings ...)
2022-08-24 17:38 ` kargl at gcc dot gnu.org
@ 2022-08-24 19:10 ` federico.perini at gmail dot com
2022-08-24 19:27 ` sgk at troutmask dot apl.washington.edu
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: federico.perini at gmail dot com @ 2022-08-24 19:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731
--- Comment #4 from federico <federico.perini at gmail dot com> ---
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug fortran/106731] ICE on automatic array of derived type with DTIO
2022-08-24 7:44 [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO federico.perini at gmail dot com
` (3 preceding siblings ...)
2022-08-24 19:10 ` federico.perini at gmail dot com
@ 2022-08-24 19:27 ` sgk at troutmask dot apl.washington.edu
2022-08-25 7:16 ` federico.perini at gmail dot com
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2022-08-24 19:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731
--- Comment #5 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Wed, Aug 24, 2022 at 07:10:20PM +0000, federico.perini at gmail dot com
wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731
>
> --- Comment #4 from federico <federico.perini at gmail dot com> ---
> 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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug fortran/106731] ICE on automatic array of derived type with DTIO
2022-08-24 7:44 [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO federico.perini at gmail dot com
` (4 preceding siblings ...)
2022-08-24 19:27 ` sgk at troutmask dot apl.washington.edu
@ 2022-08-25 7:16 ` federico.perini at gmail dot com
2022-11-08 21:11 ` anlauf at gcc dot gnu.org
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: federico.perini at gmail dot com @ 2022-08-25 7:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731
--- Comment #6 from federico <federico.perini at gmail dot com> ---
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug fortran/106731] ICE on automatic array of derived type with DTIO
2022-08-24 7:44 [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO federico.perini at gmail dot com
` (5 preceding siblings ...)
2022-08-25 7:16 ` federico.perini at gmail dot com
@ 2022-11-08 21:11 ` anlauf at gcc dot gnu.org
2022-12-23 3:13 ` jvdelisle at gcc dot gnu.org
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-11-08 21:11 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug fortran/106731] ICE on automatic array of derived type with DTIO
2022-08-24 7:44 [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO federico.perini at gmail dot com
` (6 preceding siblings ...)
2022-11-08 21:11 ` anlauf at gcc dot gnu.org
@ 2022-12-23 3:13 ` jvdelisle at gcc dot gnu.org
2022-12-23 3:47 ` jvdelisle at gcc dot gnu.org
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2022-12-23 3:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731
Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jvdelisle at gcc dot gnu.org
--- Comment #8 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug fortran/106731] ICE on automatic array of derived type with DTIO
2022-08-24 7:44 [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO federico.perini at gmail dot com
` (7 preceding siblings ...)
2022-12-23 3:13 ` jvdelisle at gcc dot gnu.org
@ 2022-12-23 3:47 ` jvdelisle at gcc dot gnu.org
2022-12-23 5:21 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2022-12-23 3:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731
--- Comment #9 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
(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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug fortran/106731] ICE on automatic array of derived type with DTIO
2022-08-24 7:44 [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO federico.perini at gmail dot com
` (8 preceding siblings ...)
2022-12-23 3:47 ` jvdelisle at gcc dot gnu.org
@ 2022-12-23 5:21 ` cvs-commit at gcc dot gnu.org
2022-12-23 20:42 ` federico.perini at gmail dot com
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-23 5:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <jvdelisle@gcc.gnu.org>:
https://gcc.gnu.org/g:7e76cd96950f49ce21246d44780e972d86b2bcdd
commit r13-4862-g7e76cd96950f49ce21246d44780e972d86b2bcdd
Author: Steve Kargl <kargl@gcc.gnu.org>
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug fortran/106731] ICE on automatic array of derived type with DTIO
2022-08-24 7:44 [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO federico.perini at gmail dot com
` (9 preceding siblings ...)
2022-12-23 5:21 ` cvs-commit at gcc dot gnu.org
@ 2022-12-23 20:42 ` federico.perini at gmail dot com
2023-01-17 20:52 ` anlauf at gcc dot gnu.org
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: federico.perini at gmail dot com @ 2022-12-23 20:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731
--- Comment #11 from federico <federico.perini at gmail dot com> ---
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
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug fortran/106731] ICE on automatic array of derived type with DTIO
2022-08-24 7:44 [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO federico.perini at gmail dot com
` (10 preceding siblings ...)
2022-12-23 20:42 ` federico.perini at gmail dot com
@ 2023-01-17 20:52 ` anlauf at gcc dot gnu.org
2023-01-18 1:00 ` jvdelisle at gcc dot gnu.org
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-01-17 20:52 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug fortran/106731] ICE on automatic array of derived type with DTIO
2022-08-24 7:44 [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO federico.perini at gmail dot com
` (11 preceding siblings ...)
2023-01-17 20:52 ` anlauf at gcc dot gnu.org
@ 2023-01-18 1:00 ` jvdelisle at gcc dot gnu.org
2023-01-21 23:09 ` cvs-commit at gcc dot gnu.org
2023-01-21 23:13 ` jvdelisle at gcc dot gnu.org
14 siblings, 0 replies; 16+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-01-18 1:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731
--- Comment #13 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
I will backport to 12 as it is an ice on Valid.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug fortran/106731] ICE on automatic array of derived type with DTIO
2022-08-24 7:44 [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO federico.perini at gmail dot com
` (12 preceding siblings ...)
2023-01-18 1:00 ` jvdelisle at gcc dot gnu.org
@ 2023-01-21 23:09 ` cvs-commit at gcc dot gnu.org
2023-01-21 23:13 ` jvdelisle at gcc dot gnu.org
14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-21 23:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731
--- Comment #14 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jerry DeLisle
<jvdelisle@gcc.gnu.org>:
https://gcc.gnu.org/g:6d307fda2b9ba71fe18f1449f7444bed7ff05193
commit r12-9055-g6d307fda2b9ba71fe18f1449f7444bed7ff05193
Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug fortran/106731] ICE on automatic array of derived type with DTIO
2022-08-24 7:44 [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO federico.perini at gmail dot com
` (13 preceding siblings ...)
2023-01-21 23:09 ` cvs-commit at gcc dot gnu.org
@ 2023-01-21 23:13 ` jvdelisle at gcc dot gnu.org
14 siblings, 0 replies; 16+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-01-21 23:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731
Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #15 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Backport complete, closing.
^ permalink raw reply [flat|nested] 16+ messages in thread