(j3.2006) Is there something wrong with this?
Daniel C Chen
cdchen
Thu Oct 29 21:19:47 EDT 2015
XLF compiles the module successfully. I don't see anything wrong with the
code.
Thanks,
Daniel
XL Fortran Development - IBM Toronto Software Lab
Phone: 905-413-3056
Tie: 969-3056
Email: cdchen at ca.ibm.com
http://www.ibm.com/software/awdtools/fortran/xlfortran
From: Van Snyder <Van.Snyder at jpl.nasa.gov>
To: j3 <j3 at j3-fortran.org>
Date: 10/29/2015 19:26
Subject: (j3.2006) Is there something wrong with this?
Sent by: j3-bounces at mailman.j3-fortran.org
I think the following module ought to be OK:
module M
type, abstract :: T1
end type T1
type, extends(t1) :: T2
end type T2
contains
class(t1) function F1 ( ) result ( R1 )
allocatable :: R1
allocate ( t2 :: r1 )
select type ( r1 )
type is ( t2 )
r1 = t2()
end select
end function F1
function F2 ( ) result ( R2 )
class(t1), allocatable :: R2
allocate ( t2 :: r2 )
r2 = t2()
end function F2
end module M
None of the processors I have will compile it. They complain in F1 that
the type of R1 is not T2, and that R1 is not polymorphic in the SELECT
TYPE statement. One of them complains about the assignment "r2 = t2()"
in F2.
Is it defective?
I believe the SELECT TYPE construct ought not to be needed. Indeed, I
believe the ALLOCATE is also not needed, but it illustrates a problem
that all my processors complain about in F1 (but which does not occur in
F2).
12.6.2.2p3 says the type and type parameters of the result of the
function may be specified by a type specification in the FUNCTION
statement. It is silent concerning whether the result is or is not
polymorphic. Is R1 polymorphic? I believe so.
_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org
http://mailman.j3-fortran.org/mailman/listinfo/j3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20151029/65b4b029/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
Url : http://mailman.j3-fortran.org/pipermail/j3/attachments/20151029/65b4b029/attachment.gif
More information about the J3
mailing list