Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29280 Discussions

Possible Bug, Self pointing structure with methods

dario83
Beginner
1,319 Views

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:

[fortran]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[/fortran]
The Output is

[bash] 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 [/bash]
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

0 Kudos
7 Replies
Kevin_D_Intel
Employee
1,319 Views
Thank you for the interesting example. I will check with Development about your mode 3 results.
0 Kudos
Kevin_D_Intel
Employee
1,319 Views
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)
0 Kudos
bucky83
Beginner
1,319 Views
Are there any updates, by any chance?

Thanks
0 Kudos
Kevin_D_Intel
Employee
1,319 Views
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.
0 Kudos
bucky83
Beginner
1,319 Views
Oh! Ok, thanks, I was just really curious!
Good to know that.
0 Kudos
Kevin_D_Intel
Employee
1,319 Views
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.
0 Kudos
Kevin_D_Intel
Employee
1,319 Views
The defect reported in this thread is fixed in our current Intel® Fortran Composer XE 2013 Initial Release (2013.0.0.079 - Linux).
0 Kudos
Reply