Bug 34785 - internal compiler error for array constructor for sequence type
Summary: internal compiler error for array constructor for sequence type
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2008-01-14 22:28 UTC by Dick Hendrickson
Modified: 2008-01-20 08:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-01-17 15:33:10


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dick Hendrickson 2008-01-14 22:28:26 UTC
I get the message

og0015.f: In function 'og0015':
og0015.f:81: internal compiler error: in gfc_trans_array_constructor, at fortran
/trans-array.c:1672

I think things work if I replace the "use o_type_defs" with the actual
contents of the module.  (Technically, this one was hard to isolate, so
I might misremember this).

Dick Hendrickson

      MODULE o_TYPE_DEFS

      TYPE SEQ

      SEQUENCE

        REAL(4)                              R, RA(9,10)
        REAL(8)                          ::  D, DA(1:10)
        REAL(10)                              Q
        REAL(KIND=10), DIMENSION(10)      ::  QA

        COMPLEX(4)                       ::  Z, ZA(0:8,1-1:9)
        COMPLEX(KIND=8), DIMENSION (20)  ::  YA(10)
        COMPLEX(8)                       ::  Y
        COMPLEX(10)                       ::  X, XA(-4:5)

        CHARACTER(9,1)                   ::  B, BA(-4:5)
        INTEGER(4)                       ::  I, IA(9,10)
        INTEGER(KIND=4)                  ::  H
        CHARACTER(1,KIND=1)            ::  C, CA(9,10)
        INTEGER(4), DIMENSION(10)        ::  HA(-4:5)

        CHARACTER(LEN=9,KIND=1)          ::  E, EA(9,10)
        LOGICAL(4)                       ::  L, LA(9,10)
        CHARACTER(KIND=1)                    F, FA(10)
        LOGICAL(4)                       ::  G, GA(10)

      END TYPE SEQ

! TEMPORARIES FOR USE WITH 'SEQ' AND 'UNSEQ' TYPES
        REAL(4)                          ::  RS_T, RA_T(9,10)
        REAL(8)                          ::  DS_T, DA_T(1:10)
        REAL(KIND=10)                     ::  QS_T, QA_T(10)

        COMPLEX(4)                       ::  ZS_T, ZA_T(0:8,0:9)
        COMPLEX(KIND=8)                  ::  YS_T, YA_T(10)
        COMPLEX(10)                       ::  XS_T, XA_T(-4:5)

        INTEGER(4)                       ::  IS_T, IA_T(9,10)
        INTEGER(4)                       ::  HS_T, HA_T(-4:5)

        LOGICAL(4)                       ::  LS_T, LA_T(9,10)
        LOGICAL(4)                       ::  GS_T, GA_T(10)

        CHARACTER(9,1)                   ::  BS_T, BA_T(-4:5)
        CHARACTER(1,KIND=1)            ::  CS_T, CA_T(9,10)
        CHARACTER(LEN=9,KIND=1)          ::  ES_T, EA_T(9,10)
        CHARACTER(KIND=1, LEN=5-4)   ::  FS_T, FA_T(10)

      END MODULE o_TYPE_DEFS


      MODULE TESTS
!  COPYRIGHT 1999   SPACKMAN & HENDRICKSON, INC.

      use o_type_defs

!      INTEGER, PRIVATE :: J1,J2,J3,J4,J5,J6,J7,JJJ
      CONTAINS
      SUBROUTINE OG0015(UDS0L)
!  COPYRIGHT 1999   SPACKMAN & HENDRICKSON, INC.
      TYPE(SEQ)          UDS0L

      UDS0L = SEQ(INT(RS_T),INT(RESHAPE((/((RA_T(J1,J2), J1 = 1,9),
     $                         J2=1,10)/), (/9,10/))),
     $            INT(DS_T),INT((/ (DA_T(J1),J1=1,10,1) /)),
     $            INT(QS_T),INT((/ (QA_T(J1), J1=10,1,-1) /)),
     $            ZS_T,RESHAPE( (/ ((ZA_T(J1,J2), J1 =0,8),
     $                         J2=0,9)/),(/9,10/)),
     $            (/ (YA_T(J1),J1=1,2*5,2-1)/),YS_T,
     $            XS_T,(/ (XA_T(J1),J1=-4, 5) /),
     $            BS_T,(/ (BA_T(J1),J1=-4, 5) /),
     $    INT(IS_T),INT(RESHAPE( (/ ((IA_T(J1,J2), J1 =1*1,3*3)
     $            ,J2= 1, 10)/), (/3*3,2*5/))), INT(HS_T),
     $            CS_T,RESHAPE ( (/ ((CA_T(J1,J2), J1 =1, 9,1),
     $                           J2=1, 2*5)/),(/8+1, 10/)),
     $            INT((/ (HA_T(J1), J1=-4,5) /)),
     $            ES_T,EA_T(1:9,1:10),
     $            LS_T,RESHAPE( (/ ((LA_T(J1,J2),J1 = 2-1,10-1),
     $                           J2=2-1,9+1)/), (/9, 10/) ),
     $            FS_T,(/ (FA_T(J1), J1=1,2*5) /),
     $            GS_T,(/ (GA_T(J1), J1= 1*1,2*5) /))

      END SUBROUTINE
      END MODULE TESTS
Comment 1 Tobias Burnus 2008-01-14 23:04:06 UTC
The failing assert is:

      /* Complex character array constructors should have been taken care of
         and not end up here.  */
      gcc_assert (ss->string_length);

Reduced test:

      MODULE o_TYPE_DEFS
        implicit none
        TYPE SEQ
          SEQUENCE
          CHARACTER(9,1) ::  BA(-4:5)
        END TYPE SEQ
        CHARACTER(9,1)   ::  BA_T(-4:5)
      END MODULE o_TYPE_DEFS

      MODULE TESTS
        use o_type_defs
        implicit none
      CONTAINS
        SUBROUTINE OG0015(UDS0L)
          TYPE(SEQ)          UDS0L
          integer :: j1
          UDS0L = SEQ((/ (BA_T(J1),J1=-4, 5) /))
        END SUBROUTINE
      END MODULE TESTS
Comment 2 Paul Thomas 2008-01-16 08:00:36 UTC
(In reply to comment #1)
It is sufficient that BA_T is referenced in tests; eg. by PRINT *, BA_T for the problem to go away.  Thus the problem is that the symbol is not being set as referenced.  I will try to find out why but will first set it referenced in gfc_resolve_variable.

Cheers

Paul
Comment 3 Paul Thomas 2008-01-17 15:33:10 UTC
I have a fix for this that I will apply as "obvious" overnight (in the EU, that is:))

Paul
Comment 4 Paul Thomas 2008-01-18 09:22:15 UTC
(In reply to comment #3)
> I have a fix for this that I will apply as "obvious" overnight (in the EU, that
> is:))
> Paul
....except that it caused a FAIL on one platform and, on another, the testsuite hung!!!  Anyway, it's on the right track and I'll try and sort it out this weekend:

gfc_check_constructor_type (gfc_expr *e)
{
  try t;

  cons_state = CONS_START;
  gfc_clear_ts (&constructor_ts);
  gfc_clear_ts (&e->ts);                  /* Fixes this bug. */

  t = check_constructor_type (e->value.constructor);
  if (t == SUCCESS && e->ts.type == BT_UNKNOWN)
    e->ts = constructor_ts;

  return t;
}

Paul
Comment 5 Paul Thomas 2008-01-18 09:33:44 UTC
(In reply to comment #4)
Sorry, the above is the fix for PR34784.

This one is fixed by:

In trans-array.c (gfc_add_loop_ss_code)

	case GFC_SS_CONSTRUCTOR:
          if (ss->expr->ts.type == BT_CHARACTER
                && ss->string_length == NULL)
            get_array_ctor_all_strlen (&loop->pre, ss->expr,
                                       &ss->string_length);
          gfc_trans_array_constructor (loop, ss);
	  break;

Paul
Comment 6 Paul Thomas 2008-01-20 08:23:43 UTC
Subject: Bug 34785

Author: pault
Date: Sun Jan 20 08:22:56 2008
New Revision: 131675

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131675
Log:
2008-01-20  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/34784
	* array.c (gfc_check_constructor_type): Clear the expression ts
	so that the checking starts from the deepest level of array
	constructor.
	* primary.c (match_varspec): If an unknown type is changed to
	default character and the attempt to match a substring fails,
	change it back to unknown.

	PR fortran/34785
	* trans-array.c (gfc_add_loop_ss_code) : If ss->string_length is
	NULL for an array constructor, use the cl.length expression to
	build it.
	(gfc_conv_array_parameter): Change call to gfc_evaluate_now to
	a tree assignment.


2008-01-20  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/34784
	* gfortran.dg/array_constructor_20.f90: New test.
	* gfortran.dg/mapping_2.f90: Correct ubound expression for h4.

	PR fortran/34785
	* gfortran.dg/array_constructor_21.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/array_constructor_20.f90
    trunk/gcc/testsuite/gfortran.dg/array_constructor_21.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/array.c
    trunk/gcc/fortran/primary.c
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/testsuite/ChangeLog

Comment 7 Paul Thomas 2008-01-20 08:44:24 UTC
Fixed on trunk

Paul