https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108611
Bug ID: 108611
Summary: [OOP] ICE with DT constructor and type->polymorphic
component in gfc_trans_structure_assign ->
gfc_trans_subcomponent_assign []
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
Target Milestone: ---
The program below fails in
0x9df788 gfc_trans_subcomponent_assign
../../repos/gcc/gcc/fortran/trans-expr.cc:9008
0x9e0515 gfc_trans_structure_assign(tree_node*, gfc_expr*, bool, bool)
../../repos/gcc/gcc/fortran/trans-expr.cc:9246
0x9e11f0 gfc_conv_structure(gfc_se*, gfc_expr*, int)
../../repos/gcc/gcc/fortran/trans-expr.cc:9313
0x9e4d23 gfc_trans_assignment_1
../../repos/gcc/gcc/fortran/trans-expr.cc:11742
I note that GCC 10 and older had:
Error: Cannot convert TYPE(dt1) to CLASS(__class_MAIN___Dt0_a) at (1)
which might give a hint about the issue. However, I regard the code as valid.
type dt0
integer :: j
end type
type, extends(dt0) :: dt1
integer :: i
end type
type dt
class(dt0), allocatable :: x
end type
type(dt) :: xdt
type(dt1) :: ydt
xdt = dt(ydt)
end