[Bug fortran/63205] [OOP] Wrongly rejects type = class (for identical declared type)

dominiq at lps dot ens.fr gcc-bugzilla@gcc.gnu.org
Fri Sep 12 15:57:00 GMT 2014


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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-09-12
     Ever confirmed|0                           |1

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
I see two issues with the test assign_11.f90:

(1) an ICE, reduced test

program test
  implicit none
  type t
    integer :: ii
  end type t
  type(t) :: y(3)

  y = func2()
contains
  function func2() result(res)
    class(t), allocatable :: res(:)
  end function func2
end program test

[Book15] f90/bug% gfc49 pr63205_red.f90
pr63205_red.f90: In function 'test':
pr63205_red.f90:8:0: internal compiler error: in gfc_trans_arrayfunc_assign, at
fortran/trans-expr.c:7369
   y = func2()
 ^

(2) a wrong code, reduced test

module m
  implicit none
  type t
    integer :: ii = 55
  end type t
contains
  subroutine sub (from, from2)
    class(t) :: from, from2(:)
    type(t) :: to, to2(3)

    if (from%ii /= 43) call abort()
    if (size (from2) /= 3) call abort()
    if (any (from2(:)%ii /= [11,22,33])) call abort()

    to = from  ! TYPE = CLASS
    to2 = from2  ! TYPE = CLASS

    print *, to%ii
!    if (to%ii /= 43) call abort()
    if (any (to2(:)%ii /= [11,22,33])) call abort()
  end subroutine sub
end module m

program test
  use m
  implicit none
  type(t), target :: x
  type(t), target :: y(3)

  x%ii = 43
  y(:)%ii = [11,22,33]
  call sub(x,y)
  x = func1()
  print *, x
!  if (x%ii /= 123) call abort()
  y = func1()
  print *, y
!  if (any (y(:)%ii /= 123)) call abort()
contains
  function func1()
    class(t), allocatable :: func1
    allocate(func1)
    func1%ii = 123
  end function func1
end program test

[Book15] f90/bug% gfc49 pr63205_red_1.f90
[Book15] f90/bug% a.out 
   167182484
   586153984
   586154000   586154000   586154000

Any objection that I open a new PR for the ICE?

> However, only "type => class" is handled. Still missing is "type = class",
> where CLASS is a (coarray) scalar or (coarray) array variable, function or
> an array constructor. See also PR 57530 comment 3.

AFAICT the assignment works for array variable, at least in the to2 context.



More information about the Gcc-bugs mailing list