I experience unexpected behavior when allocating a polymorphic array from a part of another polymorphic array. I have added a fully working program demonstrating the problem.
In both cases, I would have expected to get a TargetItems array with 5 elements. But in the first case, I get an array with 10 elements, i.e. the full size of the SourceItems array.
I have seen this behavior with the latest IVF 184.108.40.206 as well as several previous versions.
Another issue: In the debugger (using IVF 17 and VS 2015 Update 3), all arrays are shown as undefined even after the allocate...
program AllocateSourceIssueWithArraySlice implicit none type :: baseType integer aValue end type class (baseType), ALLOCATABLE :: SourceItems(:) class (baseType), ALLOCATABLE :: TargetItems(:) ALLOCATE( baseType::SourceItems(10)) print *, 'Allocating with arrayslice in SOURCE= statement' ALLOCATE( TargetItems, SOURCE=SourceItems(1:5) ) print *, 'Size SourceItems (expected 10): ', SIZE(SourceItems) print *, 'Size TargetItems (expected 5): ', SIZE(TargetItems) DEALLOCATE(TargetItems) print *, 'Allocating with arrayslice via assosciate construct' ASSOCIATE (Source => SourceItems(1:5)) ALLOCATE( TargetItems, SOURCE=Source ) END ASSOCIATE print *, 'Size SourceItems (expected 10): ', SIZE(SourceItems) print *, 'Size TargetItems (expected 5): ', SIZE(TargetItems) end program
Steve Lionel (Intel) wrote:
The fix for this might not make Update 1, but if not, definitely Update 2.
Thanks for the update on this issue.
Steve, in my original post I also mentioned that I am unable to see the variables in the above program in the debugger (VS2015 Update 3/IVF 17). Is that something specific to my installation or do have this issue as well?
The debugger issue is unrelated - the debugger still has problems with polymorphic variables. I will check with our debugger folk to make sure they're aware of this (DPD200414790).