This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/49213] [OOP] gfortran rejects structure constructor expression
- From: "neil.n.carlson at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 16 Jun 2011 20:36:07 +0000
- Subject: [Bug fortran/49213] [OOP] gfortran rejects structure constructor expression
- Auto-submitted: auto-generated
- References: <bug-49213-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49213
--- Comment #3 from neil.n.carlson at gmail dot com 2011-06-16 20:35:48 UTC ---
(In reply to comment #1)
> Note: Intrinsic assignments to polymorphic variables are forbidden [...]
This was really about the structure constructor; the assignment was
just to do something with the value, so the example was poor. Here's
a slightly different version that gets to the heart of what I intended:
program main
type :: S
integer :: n
end type
type(S) :: Sobj
type, extends(S) :: S2
integer :: m
end type
type(S2) :: S2obj
type :: T
class(S), allocatable :: x
end type
Sobj = S(1)
call pass_it (T(Sobj))
S2obj = S2(1,2)
call pass_it (T(S2obj))
contains
subroutine pass_it (foo)
type(T), intent(in) :: foo
end subroutine
end program
This gives the same errors:
call pass_it (T(Sobj))
1
Error: Can't convert TYPE(s) to CLASS(s) at (1)
call pass_it (T(S2obj))
1
Error: Can't convert TYPE(s2) to CLASS(s) at (1)