http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49213
--- Comment #8 from janus at gcc dot gnu.org 2013-01-10 15:46:12 UTC ---
(In reply to comment #7)
> I want to emphasize again that the error I wanted to report was that gfortran
> is rejecting valid structure constructor expressions (see comment 3).
Here is a slightly reduced version of comment 3:
type :: S
integer :: n
end type
type(S) :: Sobj
type :: T
class(S), allocatable :: x
end type
Sobj = S(1)
call pass_it (T(Sobj))
contains
subroutine pass_it (foo)
type(T) :: foo
end subroutine
end
One can get past the error message with the following patch:
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (revision 194927)
+++ gcc/fortran/resolve.c (working copy)
@@ -1103,7 +1103,7 @@ resolve_structure_cons (gfc_expr *expr, int init)
/* If we don't have the right type, try to convert it. */
if (!comp->attr.proc_pointer &&
- !gfc_compare_types (&cons->expr->ts, &comp->ts))
+ !gfc_compare_types (&comp->ts, &cons->expr->ts))
{
t = FAILURE;
if (strcmp (comp->name, "_extends") == 0)
but the one runs into an ICE:
internal compiler error: in fold_convert_loc, at fold-const.c:1986
call pass_it (T(Sobj))
^
0x845634 fold_convert_loc(unsigned int, tree_node*, tree_node*)
/home/jweil/gcc48/trunk/gcc/fold-const.c:1986
0x671aa9 gfc_trans_subcomponent_assign
/home/jweil/gcc48/trunk/gcc/fortran/trans-expr.c:6001
0x671e10 gfc_trans_structure_assign
/home/jweil/gcc48/trunk/gcc/fortran/trans-expr.c:6068
0x671f46 gfc_conv_structure(gfc_se*, gfc_expr*, int)
/home/jweil/gcc48/trunk/gcc/fortran/trans-expr.c:6095