This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, Fortran, OOP] PR 57306: ICE on valid with class pointer initialization
- From: Tobias Burnus <burnus at net-b dot de>
- To: fortran at gcc dot gnu dot org
- Cc: gcc patches <gcc-patches at gcc dot gnu dot org>, Janus Weil <janus at gcc dot gnu dot org>
- Date: Sat, 27 Jul 2013 11:48:43 +0200
- Subject: Re: [Patch, Fortran, OOP] PR 57306: ICE on valid with class pointer initialization
- References: <CAKwh3qgAJL9GRRDWfKp5MAx38DW=08P_CX2gV+JGEMVxkbj_fA at mail dot gmail dot com>
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