public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/105807] New: ICE / error when defining a class containing polymorphic components
@ 2022-06-01 18:45 bourdin at mcmaster dot ca
  2022-06-16 12:53 ` [Bug fortran/105807] " marxin at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: bourdin at mcmaster dot ca @ 2022-06-01 18:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105807
           Summary: ICE / error when defining a class containing
                    polymorphic components
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bourdin at mcmaster dot ca
  Target Milestone: ---

defining a class whose components are polymorphic variables fails:

Consider the following (legal) source code:
module Vect_class
    type, abstract :: Vect_Type
    end type
end module Vect_class

module Elem_class
    use Vect_class
    type, abstract :: Elem_Type
        integer                      :: numDof
        class(Vect_type),allocatable :: v
    end type
end module Elem_class

module Vect
    use Vect_class

    type, extends(Vect_Type) :: Vect2D 
       real :: X,Y
    end type Vect2D   

    type, extends(Vect_Type) :: Vect3D 
       real :: X,Y,Z
    end type Vect3D   
end module Vect

module Elem
    use Elem_class

    type, extends(Elem_type)  :: elem2D
    end type
end module Elem

program testElem
    use Vect_class
    use Vect
    use Elem_class
    use Elem

    type(Vect2D) :: a
    type(Vect3D) :: b
    class(Vect_type),allocatable :: c,d
    class(Elem_type),allocatable :: e
    real       :: x,y,z

    x = 1.0
    y =-2.0
    z = 3.0

    a = Vect2D(x,y)
    b = Vect3D(x,y,z)
    c = Vect2D(x,y)
    d = Vect3D(x,y,z)
    e = Elem2D(10,b)
    write(*,*) e%numDof
end program testElem

It fails to compile with error message with GNU Fortran (GCC) 11.2.1 20210728
(Red Hat 11.2.1-1) (RHEL7 devtoolset 11)

   53 |     e = Elem2D(10,b)
      |                  1
Error: Cannot convert TYPE(vect3d) to CLASS(__class_vect_class_Vect_type_a) at
(1)

Under macOS (monterey, M1 processor) GNU Fortran (Homebrew GCC 11.3.0_1)
11.3.0, I get an ICE:

TestNestedClass3.f90:53:20:

   53 |     e = Elem2D(10,b)
      |                    1
internal compiler error: in fold_convert_loc, at fold-const.c:2563

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

end of thread, other threads:[~2023-01-25  3:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-01 18:45 [Bug fortran/105807] New: ICE / error when defining a class containing polymorphic components bourdin at mcmaster dot ca
2022-06-16 12:53 ` [Bug fortran/105807] " marxin at gcc dot gnu.org
2022-06-21 18:48 ` gscfq@t-online.de
2022-06-23 15:38 ` gscfq@t-online.de
2023-01-25  3:42 ` abensonca 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).