Possible Bug, Self pointing structure with methods

Possible Bug, Self pointing structure with methods

I have a possible bug when using methods for structures/classes that have pointers pointing to an type implicitly passed as a method argument. Best explained with the example.

I'm compiling with non commercial intel fortran composerxe-2011.5.220.

Source is:

MODULE myTypeMod TYPE myType INTEGER :: i TYPE(myType), POINTER :: selfPointer => NULL() CONTAINS PROCEDURE, PUBLIC :: fun PROCEDURE, PUBLIC :: fun2 END TYPE myType TYPE myBox TYPE(myType), POINTER :: headList => NULL() END TYPE myBox CONTAINS !======================================================================== SUBROUTINE fun(head) CLASS(myType), TARGET, INTENT(IN) :: head WRITE(*,*) "Associated(ptr):", ASSOCIATED(head.selfPointer) WRITE(*,*) "Associated(ptr,head):", ASSOCIATED(head.selfPointer,head) WRITE(*,*) END SUBROUTINE fun !======================================================================== !======================================================================== SUBROUTINE fun2(head,head_2) CLASS(myType), TARGET, INTENT(IN) :: head TYPE(myType), TARGET, INTENT(IN) :: head_2 WRITE(*,*) "Associated(ptr):", ASSOCIATED(head.selfPointer) WRITE(*,*) "Associated(ptr,head):", ASSOCIATED(head.selfPointer,head) WRITE(*,*) "Associated(ptr,head_2):", ASSOCIATED(head.selfPointer,head_2) WRITE(*,*) END SUBROUTINE fun2 !======================================================================== END MODULE myTypeMod PROGRAM test USE myTypeMod TYPE(myBox) :: box ! Short Hands TYPE(myType), POINTER :: listHead => NULL() ! Generating list header ALLOCATE(box.headList) box%headList%selfPointer => box%headList listHead => box.headList WRITE(*,*) "Printing List mode 1" CALL fun(listHead) WRITE(*,*) "Printing List mode 2" CALL listHead.fun() WRITE(*,*) "Printing List mode 3" CALL box%headList%fun() WRITE(*,*) "Printing List mode 4" CALL box%headList%fun2(listHead) END PROGRAM test

The Output is

 Printing List mode 1 Associated(ptr): T Associated(ptr,head): T Printing List mode 2 Associated(ptr): T Associated(ptr,head): T Printing List mode 3 Associated(ptr): T Associated(ptr,head): F Printing List mode 4 Associated(ptr): T Associated(ptr,head): F Associated(ptr,head_2): T 

I'm not sure if this is a bug or just a misuse of the class methods. But "Mode 3" fails to associate the pointer belonging to the substrucure with the implicit argument of the function fun used as a class method.

Dario Isola

8 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

Thank you for the interesting example. I will check with Development about your mode 3 results.

Development's initial investigation indicated this appears to be a defect related tothe descriptor built for the actual argument (since the dummy argument is a CLASS object) and no convenient work around beyond what you show does execute correctly.

We are tracking this under the internal id noted below andI will post more when I learn it.

(Internal tracking id: DPD200173456)
(Resolution Update on 10/14/2012): This defect is fixed in the Intel® Fortran Composer XE 2013 Initial Release (2013.0.0.079 - Linux)

Are there any updates, by any chance?

Thanks

Development reported having fixed this; however,the exact availability in an upcoming update is still unclear. I will update you when I have more details about the availability of the fix.

Oh! Ok, thanks, I was just really curious!
Good to know that.

Risk of the fix is deemed high; therefore, it has been targeted to the next major release next year. I will update again once the fix is available.

The defect reported in this thread is fixed in our current Intel® Fortran Composer XE 2013 Initial Release (2013.0.0.079 - Linux).

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo!