- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a program that associates a pointer to an instance of a derived type, then checks whether the pointer is associated with the intended object. When I compile the program with ifort (19.0.4.243), the associated() function returns false.
The program is as follows:
module mod_pointer_association
type mytype
end type mytype
contains
subroutine test_association(obj)
class(mytype), target, intent(in)::obj
class(mytype), pointer::ptr
ptr=>obj
if (.not. associated(ptr)) then
print *, "ptr not associated"
error stop
end if
if (.not. associated(ptr, obj)) then
print *, "ptr not associated with obj"
error stop
end if
end subroutine test_association
end module mod_pointer_association
program test_pointer_association
use mod_pointer_association
type(mytype), target::myobj
call test_association(myobj)
end program test_pointer_association
$ ./test_pointer_association
ptr not associated with obj
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @jhaiducek
can you please try to add something to your derived type?
If I add an integer for example, your program works as you expect. Is there a real use case where you want to have an empty derived type or is this just a toy example?
Best
Tobias
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @jhaiducek
Has your issue been resolved? If I don't hear from you within 5 business days, I will assume your support request is resolved and you no longer need assistance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @jhaiducek
please open a new thread if you need further assistance.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page