public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/107872] New: ICE on recursive DT with DTIO
@ 2022-11-25 20:53 jwmwalrus at gmail dot com
  2022-11-27  0:18 ` [Bug fortran/107872] " jvdelisle at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: jwmwalrus at gmail dot com @ 2022-11-25 20:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107872
           Summary: ICE on recursive DT with DTIO
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jwmwalrus at gmail dot com
  Target Milestone: ---

Hi.

The code below throws the following ICE:

$ gfortran -c -fbacktrace test2.f90 
gfortran: internal compiler error: Segmentation fault signal terminated program
f951
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See <file:///usr/share/doc/gcc-12/README.Bugs> for instructions.

----------8<----------
module mod1
    type t
        integer :: data
        type(t), allocatable :: next
    contains
        procedure, private :: write_t
        generic :: write(formatted) => write_t
    end type
contains
    recursive subroutine write_t(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
        if (ALLOCATED(this%next)) &
            write (unit, '(dt)') this%next
    end subroutine
end module
---------->8----------


$ gfortran --version
GNU Fortran (Debian 12.2.0-9) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

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

* [Bug fortran/107872] ICE on recursive DT with DTIO
  2022-11-25 20:53 [Bug fortran/107872] New: ICE on recursive DT with DTIO jwmwalrus at gmail dot com
@ 2022-11-27  0:18 ` jvdelisle at gcc dot gnu.org
  2022-11-28  6:51 ` [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291 marxin at gcc dot gnu.org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2022-11-27  0:18 UTC (permalink / raw)
  To: gcc-bugs

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

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-11-27
                 CC|                            |jvdelisle at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
The ICE is not related to the RECURSIVE as far as I can tell. I am trying some
combinations of syntax to see if I can narrow this down.

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

* [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291
  2022-11-25 20:53 [Bug fortran/107872] New: ICE on recursive DT with DTIO jwmwalrus at gmail dot com
  2022-11-27  0:18 ` [Bug fortran/107872] " jvdelisle at gcc dot gnu.org
@ 2022-11-28  6:51 ` marxin at gcc dot gnu.org
  2022-11-28 10:01 ` pault at gcc dot gnu.org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-11-28  6:51 UTC (permalink / raw)
  To: gcc-bugs

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

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
            Summary|ICE on recursive DT with    |ICE on recursive DT with
                   |DTIO                        |DTIO since
                   |                            |r7-4096-gbf9f15ee55f5b291

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Started likely with r7-4096-gbf9f15ee55f5b291.

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

* [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291
  2022-11-25 20:53 [Bug fortran/107872] New: ICE on recursive DT with DTIO jwmwalrus at gmail dot com
  2022-11-27  0:18 ` [Bug fortran/107872] " jvdelisle at gcc dot gnu.org
  2022-11-28  6:51 ` [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291 marxin at gcc dot gnu.org
@ 2022-11-28 10:01 ` pault at gcc dot gnu.org
  2022-11-30  4:06 ` jvdelisle at gcc dot gnu.org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pault at gcc dot gnu.org @ 2022-11-28 10:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 53975
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53975&action=edit
Fix for this PR

This is a trivial bug. The ICE is occurring in resolve.cc(derived_inaccessible)
because derived types with recursive allocatable components have not been
allowed for.

With the patch, the test below does the right thing.

I am tied up with my finalization work at present. If somebody else wishes to
commit the patch, be my guest.

With a pointer component, the test runs correctly back to gfortran 7.4.1
20191027.

Cheers

Paul

! { dg-do run }
!
! Test the fix for PR107872, where an ICE occurred in
resolve.cc(derived_inaccessible)
! because derived types with recursive allocatable components were not catered
for.
!
module mod1
    type t
        integer :: data
        type(t), allocatable :: next
    contains
        procedure, private :: write_t
        generic :: write(formatted) => write_t
    end type
contains
    recursive subroutine write_t(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
        if (ALLOCATED(this%next)) &
            write (unit, '(dt)') this%next
            write (unit, '(i2)') this%data
    end subroutine
end module

  use mod1
  type(t) :: a
  character (8) :: buffer
  a%data = 1
  allocate (a%next)
  a%next%data = 2
  allocate (a%next%next)
  a%next%next%data = 3
  write (buffer, '(dt)')a
  deallocate (a%next)
  if (trim (buffer) .ne. ' 3 2 1') stop 1
end

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

* [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291
  2022-11-25 20:53 [Bug fortran/107872] New: ICE on recursive DT with DTIO jwmwalrus at gmail dot com
                   ` (2 preceding siblings ...)
  2022-11-28 10:01 ` pault at gcc dot gnu.org
@ 2022-11-30  4:06 ` jvdelisle at gcc dot gnu.org
  2022-11-30  4:08 ` jvdelisle at gcc dot gnu.org
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2022-11-30  4:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Pauls patch regression tests fine. Thanks Paul

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

* [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291
  2022-11-25 20:53 [Bug fortran/107872] New: ICE on recursive DT with DTIO jwmwalrus at gmail dot com
                   ` (3 preceding siblings ...)
  2022-11-30  4:06 ` jvdelisle at gcc dot gnu.org
@ 2022-11-30  4:08 ` jvdelisle at gcc dot gnu.org
  2022-12-09 21:09 ` anlauf at gcc dot gnu.org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2022-11-30  4:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Except WARNING: program timed out.
FAIL: gfortran.dg/merge_1.f90   -O0  execution test

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

* [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291
  2022-11-25 20:53 [Bug fortran/107872] New: ICE on recursive DT with DTIO jwmwalrus at gmail dot com
                   ` (4 preceding siblings ...)
  2022-11-30  4:08 ` jvdelisle at gcc dot gnu.org
@ 2022-12-09 21:09 ` anlauf at gcc dot gnu.org
  2022-12-09 21:28 ` anlauf at gcc dot gnu.org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-09 21:09 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #6 from anlauf at gcc dot gnu.org ---
(In reply to Paul Thomas from comment #3)
> Created attachment 53975 [details]
> Fix for this PR
> 
> I am tied up with my finalization work at present. If somebody else wishes
> to commit the patch, be my guest.

I'll submit the patch on your behalf to the ML, if you don't mind.

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

* [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291
  2022-11-25 20:53 [Bug fortran/107872] New: ICE on recursive DT with DTIO jwmwalrus at gmail dot com
                   ` (5 preceding siblings ...)
  2022-12-09 21:09 ` anlauf at gcc dot gnu.org
@ 2022-12-09 21:28 ` anlauf at gcc dot gnu.org
  2022-12-09 22:09 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-09 21:28 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pault at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #7 from anlauf at gcc dot gnu.org ---
Assigning to you, Paul, then, after submitting to the ML:

https://gcc.gnu.org/pipermail/fortran/2022-December/058603.html

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

* [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291
  2022-11-25 20:53 [Bug fortran/107872] New: ICE on recursive DT with DTIO jwmwalrus at gmail dot com
                   ` (6 preceding siblings ...)
  2022-12-09 21:28 ` anlauf at gcc dot gnu.org
@ 2022-12-09 22:09 ` cvs-commit at gcc dot gnu.org
  2022-12-18 20:02 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-09 22:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:01254aa2eb766c7584fd047568d7277d4d65d067

commit r13-4585-g01254aa2eb766c7584fd047568d7277d4d65d067
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Fri Dec 9 22:13:45 2022 +0100

    Fortran: ICE on recursive derived types with allocatable components
[PR107872]

    gcc/fortran/ChangeLog:

            PR fortran/107872
            * resolve.cc (derived_inaccessible): Skip over allocatable
components
            to prevent an infinite loop.

    gcc/testsuite/ChangeLog:

            PR fortran/107872
            * gfortran.dg/pr107872.f90: New test.

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

* [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291
  2022-11-25 20:53 [Bug fortran/107872] New: ICE on recursive DT with DTIO jwmwalrus at gmail dot com
                   ` (7 preceding siblings ...)
  2022-12-09 22:09 ` cvs-commit at gcc dot gnu.org
@ 2022-12-18 20:02 ` cvs-commit at gcc dot gnu.org
  2022-12-18 20:05 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-18 20:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:7a9741d7322357c4e777450891e43db27e067817

commit r12-8991-g7a9741d7322357c4e777450891e43db27e067817
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Fri Dec 9 22:13:45 2022 +0100

    Fortran: ICE on recursive derived types with allocatable components
[PR107872]

    gcc/fortran/ChangeLog:

            PR fortran/107872
            * resolve.cc (derived_inaccessible): Skip over allocatable
components
            to prevent an infinite loop.

    gcc/testsuite/ChangeLog:

            PR fortran/107872
            * gfortran.dg/pr107872.f90: New test.

    (cherry picked from commit 01254aa2eb766c7584fd047568d7277d4d65d067)

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

* [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291
  2022-11-25 20:53 [Bug fortran/107872] New: ICE on recursive DT with DTIO jwmwalrus at gmail dot com
                   ` (8 preceding siblings ...)
  2022-12-18 20:02 ` cvs-commit at gcc dot gnu.org
@ 2022-12-18 20:05 ` cvs-commit at gcc dot gnu.org
  2022-12-18 20:20 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-18 20:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:cc956b955d12881c9b2b970ee52b337d1ef44930

commit r11-10427-gcc956b955d12881c9b2b970ee52b337d1ef44930
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Fri Dec 9 22:13:45 2022 +0100

    Fortran: ICE on recursive derived types with allocatable components
[PR107872]

    gcc/fortran/ChangeLog:

            PR fortran/107872
            * resolve.c (derived_inaccessible): Skip over allocatable
components
            to prevent an infinite loop.

    gcc/testsuite/ChangeLog:

            PR fortran/107872
            * gfortran.dg/pr107872.f90: New test.

    (cherry picked from commit 01254aa2eb766c7584fd047568d7277d4d65d067)

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

* [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291
  2022-11-25 20:53 [Bug fortran/107872] New: ICE on recursive DT with DTIO jwmwalrus at gmail dot com
                   ` (9 preceding siblings ...)
  2022-12-18 20:05 ` cvs-commit at gcc dot gnu.org
@ 2022-12-18 20:20 ` cvs-commit at gcc dot gnu.org
  2022-12-18 20:22 ` anlauf at gcc dot gnu.org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-18 20:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:6f2f588377e6437ae23fb83aa2c85e03e1f41678

commit r10-11127-g6f2f588377e6437ae23fb83aa2c85e03e1f41678
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Fri Dec 9 22:13:45 2022 +0100

    Fortran: ICE on recursive derived types with allocatable components
[PR107872]

    gcc/fortran/ChangeLog:

            PR fortran/107872
            * resolve.c (derived_inaccessible): Skip over allocatable
components
            to prevent an infinite loop.

    gcc/testsuite/ChangeLog:

            PR fortran/107872
            * gfortran.dg/pr107872.f90: New test.

    (cherry picked from commit 01254aa2eb766c7584fd047568d7277d4d65d067)

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

* [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291
  2022-11-25 20:53 [Bug fortran/107872] New: ICE on recursive DT with DTIO jwmwalrus at gmail dot com
                   ` (10 preceding siblings ...)
  2022-12-18 20:20 ` cvs-commit at gcc dot gnu.org
@ 2022-12-18 20:22 ` anlauf at gcc dot gnu.org
  2022-12-18 20:22 ` anlauf at gcc dot gnu.org
  2022-12-18 20:22 ` anlauf at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-18 20:22 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #12 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-13, and on all open branches.  Closing.

Thanks for the report, and to Paul for the fix!

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

* [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291
  2022-11-25 20:53 [Bug fortran/107872] New: ICE on recursive DT with DTIO jwmwalrus at gmail dot com
                   ` (11 preceding siblings ...)
  2022-12-18 20:22 ` anlauf at gcc dot gnu.org
@ 2022-12-18 20:22 ` anlauf at gcc dot gnu.org
  2022-12-18 20:22 ` anlauf at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-18 20:22 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0

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

* [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291
  2022-11-25 20:53 [Bug fortran/107872] New: ICE on recursive DT with DTIO jwmwalrus at gmail dot com
                   ` (12 preceding siblings ...)
  2022-12-18 20:22 ` anlauf at gcc dot gnu.org
@ 2022-12-18 20:22 ` anlauf at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-18 20:22 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|13.0                        |10.5

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

end of thread, other threads:[~2022-12-18 20:22 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25 20:53 [Bug fortran/107872] New: ICE on recursive DT with DTIO jwmwalrus at gmail dot com
2022-11-27  0:18 ` [Bug fortran/107872] " jvdelisle at gcc dot gnu.org
2022-11-28  6:51 ` [Bug fortran/107872] ICE on recursive DT with DTIO since r7-4096-gbf9f15ee55f5b291 marxin at gcc dot gnu.org
2022-11-28 10:01 ` pault at gcc dot gnu.org
2022-11-30  4:06 ` jvdelisle at gcc dot gnu.org
2022-11-30  4:08 ` jvdelisle at gcc dot gnu.org
2022-12-09 21:09 ` anlauf at gcc dot gnu.org
2022-12-09 21:28 ` anlauf at gcc dot gnu.org
2022-12-09 22:09 ` cvs-commit at gcc dot gnu.org
2022-12-18 20:02 ` cvs-commit at gcc dot gnu.org
2022-12-18 20:05 ` cvs-commit at gcc dot gnu.org
2022-12-18 20:20 ` cvs-commit at gcc dot gnu.org
2022-12-18 20:22 ` anlauf at gcc dot gnu.org
2022-12-18 20:22 ` anlauf at gcc dot gnu.org
2022-12-18 20:22 ` anlauf 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).