Wrong array size with realloc_lhs when a type contains a allocatable class component

Wrong array size with realloc_lhs when a type contains a allocatable class component

We have a large F2003 code that runs fine on IVF12.1 but always caused unexpected behavior on IVF13.x (and also the beta IVF14.x).

After quite a long search, we were able to attribute the problem to a (in my understanding) incorrect behavior when automatically reallocating the LHS of an array assignment.

I have a attached a (minimal?) demonstrator for that issue. It needs to be compiled with F2003 semantics enabled (or realloc_lhs).

I would expect that both reallocated arrays (Target...) should have size 5, however, after assignment the TargetArrayWithAllocatableClass has the full size of the src, and not just the first 5 elements.

The bug also disappers when changing the class(ATYPE), ALLOCATABLE to a class(ATYPE), POINTER.

Best regards, Thomas

 module classdefs
 type :: AType
 real :: dummy
 end type
 type :: ClassWithAllocatableClassComponent
 class (AType), ALLOCATABLE :: dummy
 end type
 type :: ClassWithAllocatableTypeComponent
 type (AType), ALLOCATABLE :: dummy
 end type
 type PtrToClassWithAllocatableClassComponent
 type (ClassWithAllocatableClassComponent), POINTER :: ptr
 end type
 type PtrToClassWithAllocatableTypeComponent
 type (ClassWithAllocatableTypeComponent), POINTER :: ptr
 end type
 end module
 program AllocatableClassComponentBug
 use classdefs
 implicit none
 ! Variables
 type (PtrToClassWithAllocatableClassComponent), ALLOCATABLE :: SrcArrayWithAllocatableClass(:)
 type (PtrToClassWithAllocatableTypeComponent), ALLOCATABLE :: SrcArrayWithAllocatableType(:)
 type (PtrToClassWithAllocatableClassComponent), ALLOCATABLE :: TargetArrayWithAllocatableClass(:)
 type (PtrToClassWithAllocatableTypeComponent), ALLOCATABLE :: TargetArrayWithAllocatableType(:)
 integer i
ALLOCATE(SrcArrayWithAllocatableClass(10))
 ALLOCATE(SrcArrayWIthAllocatableType(10))
 TargetArrayWithAllocatableClass = SrcArrayWithAllocatableClass(1:5)
 TargetArrayWithAllocatableType = SrcArrayWithAllocatableType(1:5)
PRINT *, 'Expected size for both Targets is 5'
 PRINT *, 'Actual size for TargetArrayWithAllocatableClass is ', size(TargetArrayWithAllocatableClass)
 PRINT *, 'Actual size for TargetArrayWithAllocatableType is ', size(TargetArrayWithAllocatableType)
 end program AllocatableClassComponentBug

8 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

I have just seen that the above issue is likely related to issue DPD200243378 posten in the Linux forum a few days ago.

For what it is worth: allocatable polymorphic components require considerable "care" when working with current/recent ifort.  I've been able to get by replacing assignments with ALLOCATE(lhs%alloc_poly_component, SOURCE=rhs%alloc_poly_component) once that was supported.  Dancing on a pin head while facing north and juggling six open bottles of wine also helps, or failing that, just drink the wine.

I put some test cases together in this thread here.

It is not entirely clear to me that this is the same as Ian's issue, I'm pretty sure it's not the 244378 issue. But there is probably some commonality here.  I will report this to the developers - thanks for the example - I decided to attach it to DPD200236021 (Ian's)

Steve - Intel Developer Support

IanH,

Have you posted a link of you on Youtube of you dancing on a pin head while facing north and juggling six open bottles of wine.

I'd like to see it.

Jim ;)

www.quickthreadprogramming.com

The developers tell me that this is not the same as the earlier issue.  New issue DPD200247184 created for this one.

Steve - Intel Developer Support

Steve, thanks for keeping me informed and creating the new issue.

BR, Thomas

 

 

This uncovered multiple problems, which required fixes in the compiler and run-time library. It looks as if those will get in for the October update.

Steve - Intel Developer Support

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi