public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/106731] New: ICE on automatic array of derived type with DTIO
@ 2022-08-24  7:44 federico.perini at gmail dot com
  2022-08-24  7:49 ` [Bug fortran/106731] " marxin at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: federico.perini at gmail dot com @ 2022-08-24  7:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106731

            Bug ID: 106731
           Summary: ICE on automatic array of derived type with DTIO
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: federico.perini at gmail dot com
  Target Milestone: ---

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.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-01-21 23:13 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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
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
2023-01-21 23:09 ` cvs-commit at gcc dot gnu.org
2023-01-21 23:13 ` jvdelisle at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).