[Patch, fortran] PR20779 and PR20891 - allocation of STAT or specification variables in same call

Paul Thomas paulthomas2@wanadoo.fr
Mon Sep 18 22:17:00 GMT 2006


Erik,

> What about expressions like
>
>     allocate (x(kind(i)), stat=i)
>     allocate (x(size(i)), stat=i(1))
>
> where a variable appears in the expression determining the shape to  
> be allocated, but where the value of the variable is irrelevant?
>
> I don't think these are important cases, but since I'm not too  
> familiar with the gcc internals, I don't know whether your case  
> statements examining the expression handle that, or whether kind(i)  
> is treated like a function call.

With or without the patch in place, gfortran (ifort) compile

    integer, allocatable :: x(:)
    integer :: i, j(2)
    allocate (x(kind(i)), stat=i)
    print *, size(x)
    allocate (x(size(j)), stat=j(1))
    print *, size(x)
  end

to give

           4
           2

as they should. ie. size(i) and kind(j) are just perfectly ordinary 
expressions.  The patch was concerned to catch the non-standard case 
where STAT or a variable in the specification of other allocated arrays 
was being allocated in the same statement.

Paul



More information about the Fortran mailing list