(j3.2006) Did we intend to prevent this?
Malcolm Cohen
malcolm
Wed Nov 9 18:44:11 EST 2011
I wrote:
> That would be extremely painful - we don't want to be doing arithmetic on
> relocatable variable addresses at compile time.
Van claimed:
>What arithmetic? Fortran doesn't offer syntax for that.
Sure it does. TRANSFER it to an integer array, then you can play all kinds of
fun and games!
And after
INTEGER,PARAMETER :: ia(*) = TRANSFER(dt,[1]) + 1
you can do
CALL sub(ia)
...
SUBROUTINE sub(idum)
INTEGER idum(:)
TYPE(t) dt2
dt2 = TRANSFER(ia,dt) ! Guaranteed to give you back your original value.
...
>I'm not advocating that variable addresses, or initial data targets'
>values, be full-fledged constants.
>
>Since one can have an initial data target in a variable declaration,
>viz.
>
> character(len=42), target, save :: A
> character(len=:), pointer :: B => A
>
>and in a type definition
>
> type :: t
> character(len=:), pointer :: P => A
> end type t
>
>it just seemed inconsistent that one cannot appear as part of a
>structure constructor that is required to be a constant expression, viz.
>
> type(t), parameter :: Z = t(a)
>
>(or at least two compilers told me this is not allowed).
That's very sensible of them.
> Except Bob has
>found that according to 7.1.12p1(3)(b), t(a) is a constant expression.
Yes, so we will need an interp to fix the standard. This one does not look so
easy.
Cheers,
--
................................Malcolm Cohen, Nihon NAG, Tokyo.
More information about the J3
mailing list