public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "damian at sourceryinstitute dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/97037] New: ICE on user-defined derived-type output of an intermediate ancestor type
Date: Sun, 13 Sep 2020 01:47:54 +0000	[thread overview]
Message-ID: <bug-97037-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 97037
           Summary: ICE on user-defined derived-type output of an
                    intermediate ancestor type
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: damian at sourceryinstitute dot org
  Target Milestone: ---

The code below effectively has an abstract parent type ("object"), abstract
child type ("oracle"), and a non-abstract grandchild type ("results_t") in
which the parent has a derived-type output binding, the child has a type-bound
operator(-) associated with a deferred binding ("negative"), and the grandchild
implements both deferred bindings.  An ICE results when attempting to write the
result of the operator.  Presumably the issue is that the grandchild's operator
result must be of the child type.  The child type inherits the derived-type
output binding from the parent, but it doesn't itself explicitly state such a
binding. I lean toward thinking the code is valid, but I haven't yet consulted
the standard.

$ cat uddtio-ice.f90 
module object_interface
  implicit none

  type, abstract :: object
  contains
    procedure(write_formatted_interface), deferred :: write_formatted
    generic :: write(formatted) => write_formatted
  end type

  abstract interface
    subroutine write_formatted_interface(this, unit, iotype, vlist, iostat,
iomsg)
      import object
      implicit none
      class(object), intent(in) :: this
      integer, intent(in) :: unit, vlist(:)
      character(len=*), intent(in) :: iotype
      integer, intent(out) :: iostat
      character(len=*), intent(inout) :: iomsg
    end subroutine
  end interface

  type, abstract, extends(object) :: oracle
  contains
    procedure(negative_interface), deferred :: negative
    generic :: operator(-) => negative
  end type

  abstract interface
    function negative_interface(this)
      import oracle
      implicit none
      class(oracle), intent(in) :: this
      class(oracle), allocatable :: negative_interface
    end function
  end interface

  type, extends(oracle) :: results_t
  contains
    procedure write_formatted
    procedure negative
  end type

  interface
    module subroutine write_formatted(this, unit, iotype, vlist, iostat, iomsg)
      implicit none
      class(results_t), intent(in) :: this
      integer, intent(in) :: unit, vlist(:)
      character(len=*), intent(in) :: iotype
      integer, intent(out) :: iostat
      character(len=*), intent(inout) :: iomsg
    end subroutine
    module function negative(this)
      implicit none
      class(results_t), intent(in) :: this
      class(oracle), allocatable :: negative
    end function
  end interface
end module

  use object_interface
  write(*,*) -results_t()
end program

$ gfortran -c uddtio-ice.f90 
uddtio-ice.f90:61:0:

   61 |   write(*,*) -results_t()
      | 
internal compiler error: Segmentation fault: 11

$ gfortran --version
GNU Fortran (GCC) 11.0.0 20200804 (experimental)

             reply	other threads:[~2020-09-13  1:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-13  1:47 damian at sourceryinstitute dot org [this message]
2020-09-13 20:04 ` [Bug fortran/97037] " jvdelisle at charter dot net
2020-09-13 20:06 ` jvdelisle at charter dot net
2020-10-05 22:34 ` dominiq at lps dot ens.fr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-97037-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).