(j3.2006) Bug or interp bait?
Malcolm Cohen
malcolm
Thu Jun 6 22:52:37 EDT 2013
>Two processors say this is invalid:
>
> subroutine S ( A )
> character(len=*), intent(in) :: A
> integer, parameter :: ESize = ( storage_size(a) + 7 ) / 8
I would hope so too, and would expect it of all compilers that had STORAGE_SIZE.
>One might argue "Sure, this is invalid because a scalar with len=* might
>have a storage_size that is different from an element of an array with
>len=*, because of alignment requirements. Therefore, the 'properties
>inquired about' (7.1.12(4)(b)) are assumed."
Huh? STORAGE_SIZE(A)==LEN(A)*STORAGE_SIZE('A'), this is required by normative
text. This is rather obviously not constant, but the very epitome of "assumed".
...
>But those processors are also unhappy with
>
> integer, parameter :: ESize = ( storage_size(a(1:1)) + 7 ) / 8
>
>Was this intended to be invalid?
I certainly did not intend to allow it. Also it is definitely invalid if
LEN(A)==0 at runtime, so I would not recommend it anyway.
>If so, how does one get the storage size of a character scalar dummy
>argument? Must one create a len=1 scalar?
If you want the storage-size of something that does not have a constant storage
size, you can ask about it in an executable statement. Not being constant it is
of course not suitable for a constant expression!
If you want the storage size of a single character, why not just ask for that?
STORAGE_SIZE('A') for example, is a lot easier to read than all this convoluted
stuff.
Cheers,
--
................................Malcolm Cohen, Nihon NAG, Tokyo.
More information about the J3
mailing list