Hi, here's another one: % cat gfcbug51.f90 program gfcbug51 implicit none type date_t character(len=12) :: date = '200612231200' ! yyyymmddhhmm end type date_t type year_t integer :: year = 0 end type year_t type(date_t) :: file(1) type(year_t) :: time(1) read (file% date(1:4),'(i4)') time% year print *, time% year end program gfcbug51 % gfc gfcbug51.f90 gfcbug51.f90: In function 'MAIN__': gfcbug51.f90:1: internal compiler error: in gfc_add_modify, at fortran/trans.c:1 59 Cheers, -ha
Reduced testcase: program gfcbug51 type date_t character(len=12) :: date end type date_t type(date_t) :: file(1) read (file%date(1:4),'(i4)') a end program gfcbug51 ------------------------------ Here is a patch which fixes the issue too: Index: trans-io.c =================================================================== --- trans-io.c (revision 120165) +++ trans-io.c (working copy) @@ -635,7 +635,7 @@ set_internal_unit (stmtblock_t * block, /* The cast is needed for character substrings and the descriptor data. */ gfc_add_modify_expr (&se.pre, io, fold_convert (TREE_TYPE (io), tmp)); - gfc_add_modify_expr (&se.pre, len, se.string_length); + gfc_add_modify_expr (&se.pre, len, fold_convert (TREE_TYPE (len), se.string_length)); gfc_add_modify_expr (&se.pre, desc, se.expr); gfc_add_block_to_block (block, &se.pre);
(In reply to comment #1) > > Here is a patch which fixes the issue too: > Index: trans-io.c > The patch moves the ICE to eimt-rtl.c. laptop:kargl[218] gfc4x -o z -fdump-tree-original -O internal_io.f90 internal_io.f90: In function 'MAIN__': internal_io.f90:8: internal compiler error: in operand_subword_force, at emit-rtl.c:1352 The dump suggest that a temporary array has not been properly sized.
(In reply to comment #2) > The dump suggest that a temporary array has not been properly sized. We get: char[0:][1:12] * D.972; { int4 S.3; S.3 = 0; while (1) { if (S.3 > 0) goto L.1; (*(char[0:][1:12] *) atmp.1.data)[NON_LVALUE_EXPR <S.3>] = file[NON_LVALUE_EXPR <S.3>].date[1]{lb: 1 sz: 1}; S.3 = S.3 + 1; } L.1:; } So yes we have the incorrect type for the temp array, we have char[1:12] instead of just char. So my patch fixes one problem and we run into the next issue.
A fix is on its way, this weekend. Paul
Subject: Bug number PR30284 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-02/msg00112.html
Subject: Bug 30284 Author: pault Date: Fri Feb 2 12:35:57 2007 New Revision: 121500 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121500 Log: 2007-02-02 Paul Thomas <pault@gcc.gnu.org> PR fortran/30284 PR fortran/30626 * trans-expr.c (gfc_conv_aliased_arg): Remove static attribute from function and make sure that substring lengths are translated. (is_aliased_array): Remove static attribute. * trans.c : Add prototypes for gfc_conv_aliased_arg and is_aliased_array. * trans-io.c (set_internal_unit): Add the post block to the arguments of the function. Use is_aliased_array to check if temporary is needed; if so call gfc_conv_aliased_arg. (build_dt): Pass the post block to set_internal_unit and add to the block after all io activiy is done. 2007-02-02 Paul Thomas <pault@gcc.gnu.org> PR fortran/30284 PR fortran/30626 * io/transfer.c (init_loop_spec, next_array_record): Change to lbound rather than unity base. 2007-02-02 Paul Thomas <pault@gcc.gnu.org> PR fortran/30284 * gfortran.dg/arrayio_11.f90.f90: New test. PR fortran/30626 * gfortran.dg/arrayio_12.f90.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/arrayio_11.f90 trunk/gcc/testsuite/gfortran.dg/arrayio_12.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-expr.c trunk/gcc/fortran/trans-io.c trunk/gcc/fortran/trans.h trunk/gcc/testsuite/ChangeLog trunk/libgfortran/ChangeLog trunk/libgfortran/io/transfer.c
Subject: Bug 30284 Author: pault Date: Mon Feb 12 07:34:51 2007 New Revision: 121841 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121841 Log: 2007-02-12 Paul Thomas <pault@gcc.gnu.org> BACKPORTS FROM TRUNK PR fortran/30284 PR fortran/30626 * trans-expr.c (gfc_conv_aliased_arg): Remove static attribute from function and make sure that substring lengths are translated. (is_aliased_array): Remove static attribute. * trans.c : Add prototypes for gfc_conv_aliased_arg and is_aliased_array. * trans-io.c (set_internal_unit): Add the post block to the arguments of the function. Use is_aliased_array to check if temporary is needed; if so call gfc_conv_aliased_arg. (build_dt): Pass the post block to set_internal_unit and add to the block after all io activiy is done. PR fortran/30407 * trans-expr.c (gfc_conv_operator_assign): New function. * trans.h : Add prototype for gfc_conv_operator_assign. * trans-stmt.c (gfc_trans_where_assign): Add a gfc_symbol for a potential operator assignment subroutine. If it is non-NULL call gfc_conv_operator_assign instead of the first assignment. ( gfc_trans_where_2): In the case of an operator assignment, extract the argument expressions from the code for the subroutine call and pass the symbol to gfc_trans_where_assign. resolve.c (resolve_where, gfc_resolve_where_code_in_forall, gfc_resolve_forall_body): Resolve the subroutine call for operator assignments. PR fortran/30514 * array.c (match_array_element_spec): If the length of an array is negative, adjust the upper limit to make it zero length. 2007-02-12 Paul Thomas <pault@gcc.gnu.org> PR fortran/30284 * gfortran.dg/arrayio_11.f90: New test. PR fortran/30626 * gfortran.dg/arrayio_12.f90: New test. PR fortran/30407 * gfortran.dg/where_operator_assign_1.f90: New test. * gfortran.dg/where_operator_assign_2.f90: New test. * gfortran.dg/where_operator_assign_3.f90: New test. PR fortran/30514 * gfortran.dg/zero_sized_2.f90: New test. 2007-02-12 Paul Thomas <pault@gcc.gnu.org> PR fortran/30284 PR fortran/30626 * io/transfer.c (init_loop_spec, next_array_record): Change to lbound rather than unity base. Added: branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/arrayio_11.f90 branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/arrayio_12.f90 branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/where_operator_assign_1.f90 branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/where_operator_assign_2.f90 branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/where_operator_assign_3.f90 branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/zero_sized_2.f90 Modified: branches/gcc-4_2-branch/gcc/fortran/ChangeLog branches/gcc-4_2-branch/gcc/fortran/array.c branches/gcc-4_2-branch/gcc/fortran/resolve.c branches/gcc-4_2-branch/gcc/fortran/trans-expr.c branches/gcc-4_2-branch/gcc/fortran/trans-io.c branches/gcc-4_2-branch/gcc/fortran/trans-stmt.c branches/gcc-4_2-branch/gcc/fortran/trans.h branches/gcc-4_2-branch/gcc/testsuite/ChangeLog branches/gcc-4_2-branch/libgfortran/ChangeLog branches/gcc-4_2-branch/libgfortran/io/transfer.c
Fixed on trunk and 4.2. Paul
Subject: Bug 30284 Author: pault Date: Sat Jun 30 13:08:19 2007 New Revision: 126147 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126147 Log: 2007-06-30 Paul Thomas <pault@gcc.gnu.org> PR fortran/32472 * simplify.c (gfc_simplify_repeat): Add handling of character literal for first argument. 2007-06-30 Paul Thomas <pault@gcc.gnu.org> PR fortran/30284 * gfortran.dg/repeat_f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/repeat_5.f90 Modified: trunk/gcc/fortran/simplify.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 30284 Author: pault Date: Sat Jun 30 13:09:14 2007 New Revision: 126148 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126148 Log: 2007-06-30 Paul Thomas <pault@gcc.gnu.org> PR fortran/32472 * simplify.c (gfc_simplify_repeat): Add handling of character literal for first argument. 2007-06-30 Paul Thomas <pault@gcc.gnu.org> PR fortran/30284 * gfortran.dg/repeat_f90: New test. Modified: trunk/gcc/fortran/ChangeLog