Hi Janus,
Janus Weil wrote:
here is a fix for class pointer initialization.
I think the patch looks reasonable. However, as soon as I try to use the
variable, I get an ICE in write_global_declarations -> symtab_get_node.
It works if one moves the targets into a module.
I wonder whether there is an ordering problem of the decl or something
else. The dump has:
static struct __class_MAIN___C_p cc = &cd;
struct c cd;
static struct __class_MAIN___C_p dc = ⅆ
struct d dd;
Additionally, the CLASS are wrongly initialized: You only set "_data"
(indirectly as it is the first field/component of the class) but you do
not set the _vptr component. Hence, the my example fails at run time
Tobias
PS: The test case. With module - fails at run time for same_type_as.
Without module - one gets an ICE.
!module m
type :: c
end type c
type, extends(c) :: d
end type d
type(c), target :: cd
type(d), target :: dd
!end module m
! use m
class(c), pointer :: cc => cd
class(c), pointer :: dc => dd
if(.not. associated(cc, cd)) call abort() ! OK
if(.not. same_type_as(cc, cd)) call abort() ! Fails
if(.not. associated(dc, dd)) call abort() ! OK
if(.not. same_type_as(dc, dd)) call abort() ! Fails
end