[J3] Question on function result characteristic in context of an extensibe type with SAME_TYPE_AS intrinsic
Bill Long
longb at cray.com
Wed Jul 3 10:38:27 EDT 2019
The type of the A argument to same_type_as is type(t). The result type for the function new_t() is also type(t). Since type(t) qualifies as extensible, the error message from compiler “another” seems bogus. Besides, there is no polymorphism here, so A and B pretty clearly have the same type. I don’t see a standard violation.
Cheers,
Bill
> On Jul 3, 2019, at 9:22 AM, Vipul Parekh via J3 <j3 at mailman.j3-fortran.org> wrote:
>
> Consider the following:
>
> module m
> type :: t
> integer :: i = 0
> end type
> contains
> function new_t( i ) result(n)
> integer, intent(in) :: i
> type(t) :: n
> n%i = i
> end function
> function f( u ) result(l)
> type(t), intent(in) :: u
> logical :: l
> l = same_type_as( A=u, B=new_t(i=42) )
> end function
> end module
>
> One processor compiles the above code ok whereas another one issue an
> error with the same_type_as intrinsic in connection with argument B
> not being an extensible type.
>
> A question therefore: does the above code conform to the standard?
>
> Thanks,
> Vipul Parekh
Bill Long longb at cray.com
Principal Engineer, Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9143
Cray Inc./ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425
More information about the J3
mailing list