assumed size final subroutine interface

assumed size final subroutine interface

D.W. van Meeuwen的头像

Hello,

I have a question regarding the interface of the final subroutines. According to the Fortran 2003 standards, you can have multiple final bindings, with the following restriction: any two final subroutines for a type must differ in the rank of kind type paramters of the dummy argument. The same final subroutine may not be specified twice.

In the attached small fortran file, I have created an type:
TYPEDerivedQuantityType INTEGER,DIMENSION(:),POINTER::Unit=>null() CONTAINS FINAL::FreeDerivedQuantity FINAL::FreeDerivedQuantities
...
ENDTYPEDerivedQuantityType
Where the interface only differs in rank:
- FreeDerivedQuantities(:)
- FreeDerivedQuantity

This type is part of another type:
TYPEQuantityType TYPE(DerivedQuantityType),DIMENSION(:),POINTER::DerivedQuantity=>null()
CONTAINS
...
ENDTYPEQuantityTypeI use the generic assignment (=) for the derived type (see also the attached file),
NewQuantityType%DerivedQuantity(1)=OldQuantityType%DerivedQuantity(1) The generic assignment has an intent(out) attribute on the DerivedQuantity. The compiler then will deallocate the header argument when the routine is called.

I would have assumed that it is calling the FreeDerivedQuantity routine. However, when I debug the session, I notice that it does use the FreeDerivedQuantities routine, resulting in an access violation.

Does anyone has an explanation for this behavior?

Kind Regards,
Dirk van Meeuwen

附件尺寸
下载 testprogram.f903.56 KB
4 帖子 / 0 new
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项.
D.W. van Meeuwen的头像

As a workaround putting the INTENT(inout) attribute for the assign routines can be used. In my opinion this should not be necessary.

Steve Lionel (Intel)的头像

I agree that this behavior is not correct. I have escalated it to the developers as issue DPD200232729. I will update this thread when I have news.

Steve
Steve Lionel (Intel)的头像

This has been fixed for a release later this year.

Steve

登陆并发表评论。