Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Linked list of extended types

pterminator
Beginner
1,000 Views
Hello,

While trying to build a linked list of extended types, I came upon the following problem. The association of the next pointer cannot be done directly, but results in a segmentation fault. I have attached an example that demonstrates the problem. All compilations were done with:

Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20091012 Package ID: l_cprof_p_11.1.059

which is the latest version as far as I know.

Any help?

program example

implicit none

type :: p_type
class(p_type),pointer::next=>null()
end type

type, extends(p_type)::pz_type
double complex::z
end type

type, extends(p_type)::pr_type
double precision::r
end type

class(p_type),pointer::p=>null(),cp=>null(),cp2=>null()


allocate(pr_type :: p)
cp=>p
select type(cp)
type is (pr_type)
cp%r=1d0
end select

!like it should work, but doesn't
! cp=>cp%next

!workaround:
cp2=>cp%next
cp=>cp2 !rather useless

end program example




0 Kudos
5 Replies
Kevin_D_Intel
Employee
1,000 Views

Thank you for reporting this and for the convenient reproducer. Sure looks like a bug. I reported it to Development and will keep this thread updated as I learn more.

(Internal tracking id: DPD200148476)
0 Kudos
pterminator
Beginner
1,000 Views


A great, thanks for the response.

I just wanted to add that if you allocate the next pointer (as any type within the class), then the pointer association is no problem (cp=>cp%next). However, when cycling through a linked list then the situation described above will (of course) occur at the end of the list. It seems to me that the problem must lie with the null() pointer.

Thanks again.

0 Kudos
Kevin_D_Intel
Employee
1,000 Views

Thanks. I passed that extra information along to Development. I'll keep you posted.
0 Kudos
Kevin_D_Intel
Employee
1,000 Views
I confirmed this defect will be fixed in the upcoming 11.1 update 5 in late January/early February.
0 Kudos
Kevin_D_Intel
Employee
1,000 Views
11.1 Update 5 (11.1.069 - Linux) is now available.
0 Kudos
Reply