wrong result traversing linked list with ifort 12

wrong result traversing linked list with ifort 12

using:

ifort (IFORT) 12.0.0 20101006

In this test case, I create a linked list of 4 elements with polimorphic objects, and when I traverse it, it only prints 3 of them.
using an alternate advance instruction, it shows all 4 objects, but it should work in both cases.

the output is:

---
35082336 0 0
35082496 0 0
35082656 0 0
---
35082336 0 0
35082496 0 0
35082656 0 0
35082816 0 0
---

that has 3 + 4 lines, but it should have 4 + 4 lines. the exact numbers shown may differ.

this is the attachment:
http://software.intel.com/file/m/32517
 

AttachmentSize
Download linked_list_3.f90765 bytes
4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

yes, looks like a bug. I've modified the source a little to make it more clear where the bug is happening:

program pe

type, abstract :: t
integer :: i = 1
class(t), pointer :: next => null()
integer :: j = 2
end type

type, extends(t) :: u
integer :: k = 3
end type

type, extends(t) :: v
integer :: l = 4
end type

class(t), pointer :: ini => null()
class(t), pointer :: p => null()
class(t), pointer :: temp => null()

allocate(u :: ini)
allocate(v :: ini%next)
allocate(u :: ini%next%next)
allocate(v :: ini%next%next%next)

print *, '---'

p => ini

do while (associated(p))
print *, "current element", loc(p),"next associated?-->",associated(p)
print *, " traverse to next element "
p => p%next
print *, "next element", loc(p),"next associated?-->",associated(p)
print *, " "
enddo

print*, "exited loop - why?"
print *, '---'

p => ini

do while (associated(p))
print *, "current element", loc(p),"next associated?-->",associated(p)
print *, " traverse to next element "
temp => p%next
p => temp
print *, "next element", loc(p),"next associated?-->",associated(p)
print *, " "
enddo

print *, '---'

deallocate(ini%next%next%next)
deallocate(ini%next%next)
deallocate(ini%next)
deallocate(ini)

end program

I'll start a bug report

bug report ID is DPD200163749

btw - this is a very clean and nice example of using F03 to create linked lists! Great use of F03 features.

ron

this bug was fixed some time ago.  marking it closed, thanks for sending this to us!

Login to leave a comment.