Here is a variant: Apart from SELECT TYPE, this bug can also be exposed via the SAME_TYPE_AS intrinsic.
module Tree_Nodes
type treeNode
contains
procedure :: walk
end type
contains
subroutine walk (thisNode)
class (treeNode) :: thisNode
print *, SAME_TYPE_AS (thisNode, treeNode())
end subroutine
end module
module Merger_Trees
use Tree_Nodes
private
public :: mergerTree
type mergerTree
type(treeNode), pointer :: baseNode
end type
end module
module Merger_Tree_Build
use Merger_Trees
end module
program test
use Merger_Tree_Build
use Tree_Nodes
type(treeNode) :: node
call walk (node)
end program
This prints "F", but should print "T".
The underlying problem seems to be related to the vtable not being properly set up. The vtab symbol for the type 'treeNode' apparently is present, but it is not initialized properly: The '_hash' component is 0!
Looking at the mod files, the symbol '__vtab_tree_nodes_Treenode' seems to be present in tree_nodes.mod and merger_tree_build.mod, but not in merger_trees.mod!