Assignment to an allocatable array not working (using -assume realloc_lhs)

Assignment to an allocatable array not working (using -assume realloc_lhs)

If you use the -assume realloc_lhs or -standard-semantics compile flags to get standard-conforming behavior, assignment to an allocatable lhs array works properly under most circumstances.  However, here is an example (attached) where it doesn't.  In this case the rhs vector is polymorphic and the assignment statement is in one of the TYPE IS stanzas of a SELECT TYPE construct applied to the polymorphic vector.  This is standard conforming and works with other compilers, but the Intel 14.0.2 compiler produces code that gives a run-time error at that assignment statement.  See the attached example.

Download intel-bug-20140424.f902.23 KB
6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Thank you for reporting this and for the convenient reproducer Neil. I have reproduced this and escalated it to our Fortran Development team (see internal tracking id below) for analysis/repair and will keep your post updated regarding the status of a fix.
(Internal tracking id: DPD200255963)


Is this a regression, meaning it worked previously but got broken due to other changes in the compiler?  I ask because I think I've used such a feature successfully in some of my code built most likely with compiler version 13 on Windows but it may take me some time to dig through a ton of code across many libraries to find it.


FortranFan, Your situation may be different, but in my case I'm seeing this error for 13.1.2 as well.

It does not appear to be a regression. My findings concur with Neil's. I checked back to 12.1 where it was also present. It is also present in the current 15.0 Beta compiler.

Incidently, my work-around for the assignment in

select type (v)
type is (integer)
  val = v
end select

is to replace it with

  if (allocated(val)) deallocate(val)
  allocate(val(size(v)), source=v)

It's not exactly the same (val is always reallocated) but it's working in my use cases.

Login to leave a comment.