[J3] Standard conformance of parameterized derived type usage

Malcolm Cohen malcolm at nag-j.co.jp
Tue Nov 10 20:25:46 EST 2020


Well, it's standard-conforming, but opinions differ as to whether it is
reasonable code.

The same question can be asked with KIND type parameters btw.

As it defines an infinite recursion with different type parameter values at
every level, it is not unreasonable for a compiler to reject it on the
grounds that it doesn't have infinite memory to store the descriptors. (Yes,
there are techniques to handle this, but they perform worse for the cases
when one is not doing an infinite recursion.)

I did not find a compiler that did not either give a nonsense error, an
internal error, a "we haven't done this yet 'cause it's too hard" error, or
garbage output. One did both garbage output for LEN, internal error for
KIND.

BTW the output should obviously be 0, 1, 2.

However, given the amount of "good stuff" that everyone has to implement,
one would have to be sympathetic to the view that handling a definition of
an infinite recursion of different type parameter values would be very low
priority on the "to do" list.

Perhaps a more interesting question is whether it *should* be valid Fortran.
It's not that it is impossible to implement, but it is certainly a lot of
complication for little to no gain. I am sympathetic to that argument too.

Cheers,
-- 
..............Malcolm Cohen, NAG Oxford/Tokyo.

-----Original Message-----
From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of William Clodius
via J3
Sent: Wednesday, November 11, 2020 10:05 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: William Clodius <w.clodius at icloud.com>
Subject: Re: [J3] Standard conformance of parameterized derived type usage

ThaNKS. Now suppose the initialization to a null pointer is omitted is it
standard conforming etc.?

> On Nov 10, 2020, at 5:52 PM, Malcolm Cohen via J3
<j3 at mailman.j3-fortran.org> wrote:
> 
> No, it is not conforming, it violates a constraint:
> 
> C762 (R737) If component-initialization appears, every type parameter and
> array bound of the component shall be a colon or constant expression.
> 
> Cheers,
> -- 
> ..............Malcolm Cohen, NAG Oxford/Tokyo.
> 
> -----Original Message-----
> From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of William Clodius
> via J3
> Sent: Wednesday, November 11, 2020 9:36 AM
> To: General J3 interest list <j3 at mailman.j3-fortran.org>
> Cc: William Clodius <w.clodius at icloud.com>
> Subject: [J3] Standard conformance of parameterized derived type usage
> 
> Is the following program standard conforming?
> 
> PROGRAM TEST_LEN_PARAMETER
>    IMPLICIT NONE
>    TYPE :: T(N)
>        iNTEGER, LEN :: N
>        TYPE(T(N+1)), POINTER :: P => NULL()
>    END TYPE T
>    TYPE(T(0)) :: A
>    ALLOCATE(A % P)
>    ALLOCATE(A % P % P)
>    WRITE(*,'(A, I0)') 'A % N = ', A % N
>    WRITE(*,'(A, I0)') 'A % P % N = ', A % P % N
>    WRITE(*,'(A, I0)') 'A % P % P % N = ', A % P % P % N
> END PROGRAM TEST_LEN_PARAMETER
> 
> If so what should be the output?
> 
> If so are there any processors that successfully process the code?
> 
> 




More information about the J3 mailing list