(j3.2006) Intrinsic assignment of derived types
Steve Lionel
steve
Sat Feb 3 17:45:38 EST 2018
Consider:
type :: t
end type
type, extends(t) :: e
end type
type(t) :: foo
class(t), allocatable :: bar
allocate( e :: bar )
foo = bar
end
Is the assignment of bar to foo valid, and if so, what does it do?
Referencing 18-007, 10.2.1.2 requires that the type of the expr be "the
same derived type as the variable". Here they are of the same declared
type, but not the same dynamic type.
Then in 10.2.1.3p13,? it says, "An intrinsic assignment where the
variable is of derived type is performed as if each component of the
variable
were assigned from the corresponding component of expr..." One could
interpret this as copying only the components of bar that are in foo.
One compiler I have access to allows this, another does not, complaining
that the types don't match.
What exactly does "same derived type" mean here? Would it be
correct/useful to change the words in table 10.8 to say "same dynamic type"?
Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.j3-fortran.org/pipermail/j3/attachments/20180203/b0f2dcfb/attachment.html>
More information about the J3
mailing list