(j3.2006) Bug or interp bait?

Van Snyder Van.Snyder
Thu Jun 6 20:42:38 EDT 2013


Two processors say this is invalid:

  subroutine S ( A )
    character(len=*), intent(in) :: A
    integer, parameter :: ESize = ( storage_size(a) + 7 ) / 8
    ! ...
  end subroutine S

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."

But those processors are also unhappy with

    integer, parameter :: ESize = ( storage_size(a(1:1)) + 7 ) / 8

Was this intended to be invalid?

If so, how does one get the storage size of a character scalar dummy
argument?  Must one create a len=1 scalar?

I tried

  subroutine S ( A )
    character(len=*), intent(in) :: A
    character :: B
    integer, parameter :: ESize = ( storage_size(b) + 7 ) / 8
    ! ...
  end subroutine S

but one processor still objects to that.

Finally, I tried

  subroutine S ( A )
    character(len=*), intent(in) :: A
    character, parameter :: B = ''
    integer, parameter :: ESize = ( storage_size(b) + 7 ) / 8
    ! ...
  end subroutine S

and everybody was happy.





More information about the J3 mailing list