[J3] Question on parent component naming

John Reid john.reid9 at talktalk.net
Mon Apr 8 15:51:22 UTC 2024


Reinhold,

I believe that your program is standard-conforming. 14.2.2, para 7 says

An accessible entity in the referenced module is associated with one or 
more accessed entities, each with its own identifier. These identifiers are
  • the identifier of the entity in the referenced module if that 
identifier appears as an only-use-name or as the defined-operator of a 
generic-spec in any only for that module,
• each of the local-names or local-defined-operators that the entity is 
given in any rename for that module,  and
• the identifier of the entity in the referenced module if that 
identifier does not appear as a use-name or use-defined-operator in any 
rename for that module.

This is saying that rename really does renaming. The entity is known by 
its new name and is not known by its original name. So your code behaves 
like this code

PROGRAM ref_parent


    TYPE :: my_t

       REAL, POINTER :: p(:) => null()

    END TYPE

    TYPE, EXTENDS(my_t) :: td

      REAL :: data(3)

    END TYPE

    TYPE(td), TARGET :: o_my_t

    o_my_t%my_t = my_t(o_my_t%data)  ! (x)

    ! o_my_t%t = my_t(o_my_t%data)       ! (y)

END PROGRAM

which looks good to me, but not if you replace (x) by (y).

I think NOTE 1 in 7.5.7.1 is just doing what notes do - clarifying what 
has already been defined normatively.

Cheers,

John.




Bader, Reinhold via J3 wrote:
>
> Dear J3,
>
> consider the following program:
>
> MODULE mod
>
>    TYPE :: t
>
>       REAL, POINTER :: p(:) => null()
>
>    END TYPE
>
> END MODULE
>
> PROGRAM ref_parent
>
>    USE mod, my_t => t
>
>    TYPE, EXTENDS(my_t) :: td
>
>      REAL :: data(3)
>
>    END TYPE
>
>    TYPE(td), TARGET :: o_my_t
>
>    o_my_t%my_t = my_t(o_my_t%data)  ! (x)
>
>    ! o_my_t%t = my_t(o_my_t%data)       ! (y)
>
> END PROGRAM
>
> Two compilers accept this code. Two other compilers tell me that my_t 
> is not a parent component of o_my_t, at (x)
>
> One of those two others accepts the variant statement (y), the other 
> one crashes when (y) is used.
>
> I tend to believe that the above is conforming, but this is based on 
> non-normative evidence (NOTE 1 in 7.5.7.1 of 24-007).
>
> Any opinions?
>
> Regards
>
> Reinhold
>




More information about the J3 mailing list