pointers - LOC() for user defined types gives different results depending on the context -


i'm trying debug code in members of user defined object mysteriously change addresses, , while doing realized user defined objects well. here's small example of querying object address function created , member function:

  module foo_module      type foo_type       contains         procedure :: foo     end type foo_type      contains        subroutine foo(this)         class(foo_type) ::         print *, 'inside foo is', loc(this)       end subroutine foo    end module foo_module     program trial      use foo_module     type(foo_type) :: object      print *, 'object address', loc(object)     call object%foo()    end program trial 

a sample output is:

object address            4452052800 inside foo       140734643354880 

why getting 2 different addresses same object? doing wrong? or there loc comes play don't understand?

i'm using ifort under osx.

loc extension. behaviour specified compiler vendor.

what behaviour intended vendor here isn't clear, difference seeing in main program integer equivalent of memory address of non-polymorphic object (what expect), while in subroutine integer equivalent of memory address of polymorphic descriptor object (maybe want, maybe not).

using transfer(c_loc(xxx), 0_c_intptr_t) more portable way of getting integer representation of address of object (where c_* things iso_c_binding intrinsic module). c_loc requires argument have target attribute , non-polymorphic (use select type).

i'd recommend asking on relevant intel forum if want further clarification on intended behaviour of loc extension.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -