(j3.2006) Comment 1 from TS Ballot

Malcolm Cohen malcolm
Thu Sep 6 21:45:18 EDT 2012


Bill Long writes:

<<<
I should have pointed out a more specific rule at [121:10-12] :

"An assumed-size array (5.3.8.5) is permitted to appear as a whole array
in an executable construct or specification expression only as an actual
argument in a procedure reference that does not require the shape."

If the dummy argument is intent(out) and the type has allocatable
components, then I would argue that the shape is required.
>>>

Technically speaking, it does not require the shape but only the size.

One might also argue that it does not require either if all the components are 
already deallocated!

<<<
  There are
other cases where the shape would not be required (no intent(out), for
example).   Would a Note following the above paragraph in Clause 6 be
appropriate / sufficient?
>>>

I think this needs to be normative text, in fact a constraint is probably best. 
When the actual argument is assumed-size, assumed-rank acts just like 
assumed-size and therefore when the actual is assumed-size an INTENT(OUT) 
assumed-rank dummy needs the same restrictions; these are listed in C534 and are
(a) not polymorphic
(b) not finalizable
(c) not have an ultimate allocatable component
(d) not have default initialization
All of these specify user-visible effects!

I.e. something like
  Cxyz If an assumed-size array is an actual argument corresponding to a dummy 
argument that is an INTENT(OUT) assumed-rank array, it shall not be polymorphic, 
finalizable, of a type with an allocatable ultimate component, or of a type for 
which default initialization is specified.

Actually due to transitivity this needs to catch all assumed-rank objects that 
don't have the ALLOCATABLE or POINTER attributes to, otherwise the bad things 
happen one calling level down, so that constraint needs to begin
  Cxyz If an assumed-size or nonallocatable nonpointer assumed-rank array is ...

Yes normative text, yes constraint.  We want to require diagnosis at compile 
time: this is sufficiently subtle that people are going to have difficulty 
working it out from the standard let alone noticing it before writing incorrect 
code.

I know this looks a bit draconian, but it is only hitting INTENT(OUT) 
assumed-rank so most of the functionality is preserved.

Cheers,
-- 
................................Malcolm Cohen, Nihon NAG, Tokyo. 




More information about the J3 mailing list