[J3] type definitions

Kurt W Hirchert kurthirchert at gmail.com
Sat Aug 13 19:38:40 UTC 2022

On 8/10/2022 5:18 PM, Robert Corbett via J3 wrote:
> Is the program
>         TYPE T
>           REAL(KIND=KIND(X)) Y
>         END TYPE T
>       END
> standard conformant?
> What about the program
>         TYPE T
>           REAL(KIND=KIND(X)) X
>         END TYPE T
>       END
> ?
> Some of the text in the Fortran 2008
> standard and Corrigendum 1 that
> applies to these programs seems to
> be missing in the Fortran 2018
> standard and the 2023 draft.
> Robert Corbett
Several people have said thought that both programs conform.  I come to 
a different conclusion, so I would appreciate it if people could point 
out where they disagree with my reasoning.  (It's been nearly two 
decades since I was on the committee, so my grasp of the fine details of 
the standard may not be what it used to be.)

I see the first program as conforming, independent of the question of 
the "missing" text.  Since X is not declared explicitly, it is 
implicitly declared to be default real, so the KIND for Y is established 
regardless of the question of whether X is a part of T or of MAIN.  For 
reasons having nothing to do with this example, it is important that X 
not be part of T (because we don't want undeclared components in T), so 
I hope that Malcolm's comments that the "missing" text was unnecessary 
means that this is expressed more clearly somewhere else in the draft.  
Could we get a hint as to where?

I see the second program as not confirming.  The explicit declaration of 
a component X in T prevents T from accessing the X in MAIN by host 
association, so KIND(X) can only be referencing the component X, but 
this violates the requirement that the explicit declaration of X precede 
the KIND(X) reference.  I can imagine reasons why a compiler might fail 
to diagnose this, so I don't take compiler acceptance of this program as 
a strong indication of how the standard should be interpreted in this 

Am I missing something?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20220813/2b221ecb/attachment.htm>

More information about the J3 mailing list