This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: (Re)allocation of allocatable arrays on assignment - F2003


On 11/04/2010 09:56 AM, Tobias Burnus wrote:
On 11/04/2010 09:50 AM, Tobias Burnus wrote:
Bootstrapped and regtested on FC9/x86_64 - OK for trunk?

Before you commit, can you add [...]

Another post script: Can you add a condition that no reallocation happens for coarrays/coindexed variables? That's not a correctness issue (the RHS must have the same size as the LHS -- otherwise the program is invalid) but a performance issue. [Actually, in terms of array bounds, it might also be a correctness issue.]


Example:

subroutine sub
  integer, allocatable :: a(:)[:]
  a = [8] ! Right-most partref of LHS is a coarray (attr.codimension != 0)
end

type t
   integer, allocatable :: alloc_comp(:)
end type t
contains
subroutine sub2(a)
  type(t) :: a[*]
  a[1]%alloc_comp = [8] ! LHS is coindexed
end

Cf. F2008, "7.2.1.2 Intrinsic assignment statement":

"In an intrinsic assignment statement, [...] (3) the variable and expr shall be
conformable unless the variable is an allocatable array that has the same rank
as expr and is neither a coarray nor a coindexed object,"


The attr.codimension check can be added at the same place as the attr.allocatable check as both is with regards to the right most partref. The coindexed check can be done by calling gfc_is_coindexed (expr).


Tobias


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]