Bug 38914 - [4.3 only] ICE with array inquiry functions above contains in parameter expression
[4.3 only] ICE with array inquiry functions above contains in parameter expre...
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: fortran
4.4.0
: P4 normal
: ---
Assigned To: Thomas Koenig
: ice-on-valid-code
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2009-01-19 16:48 UTC by Dick Hendrickson
Modified: 2009-06-07 14:39 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.4.0 4.5.0
Known to fail: 4.2.5 4.3.3
Last reconfirmed: 2009-01-19 17:56:51


Attachments
patch (5.28 KB, patch)
2009-01-26 21:04 UTC, Thomas Koenig
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dick Hendrickson 2009-01-19 16:48:54 UTC
The following program causes an ICE.  If the contains and subroutine statements are uncommented, then the program compiles.

Dick Hendrickson

      MODULE U_above_TESTS

! fails on Windows XP
! gcc version 4.4.0 20081219 (experimental) [trunk revision 142842] (GCC)

!      contains
!      subroutine U_below

      INTEGER, PARAMETER, DIMENSION(0:20,4) :: IP_ARRAY2_4_S = 0

      INTEGER, PARAMETER, DIMENSION(12) ::  IP_ARRAY1_32_S =
     $(/  LBOUND(IP_ARRAY2_4_S), LBOUND(IP_ARRAY2_4_S(5:10,2:3)),
     $    UBOUND(IP_ARRAY2_4_S), UBOUND(IP_ARRAY2_4_S(5:10,2:3)),
     $    SIZE(IP_ARRAY2_4_S), SIZE(IP_ARRAY2_4_S(5:10,2:3)),
     $    SHAPE(IP_ARRAY2_4_S(5:10,2:3))  /)

!      end subroutine u_below

      END MODULE U_above_TESTS


C:\gfortran>gfortran u_above.f
f951.exe: internal compiler error: in gfc_conv_array_initializer, at fortran/tra
ns-array.c:4009
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 kargl 2009-01-19 17:56:51 UTC
Reduced testcase.  This appears to be an array section problem
with lbound().

      MODULE U_above_TESTS
      INTEGER, PARAMETER, DIMENSION(0:20,4) :: IP_ARRAY2_4_S = 0
      INTEGER, PARAMETER, DIMENSION(2) ::  IP_ARRAY1_32_S =
     $(/  LBOUND(IP_ARRAY2_4_S(5:10,2:3))/)
      END MODULE U_above_TESTS
Comment 2 Mikael Morin 2009-01-19 19:47:27 UTC
the lbound should be simplified in simplify_bound even if the ARRAY argument is not a full array.
Comment 3 Thomas Koenig 2009-01-26 09:11:20 UTC
(In reply to comment #2)
> the lbound should be simplified in simplify_bound even if the ARRAY argument is
> not a full array.
> 

Here's a tentative patch:

Index: simplify.c
===================================================================
--- simplify.c  (revision 143655)
+++ simplify.c  (working copy)
@@ -2251,6 +2251,8 @@ simplify_bound (gfc_expr *array, gfc_exp
              continue;

            case AR_FULL:
+           case AR_SECTION:
+
              /* We're done because 'as' has already been set in the
                 previous iteration.  */
              if (!ref->next)
@@ -2258,7 +2260,6 @@ simplify_bound (gfc_expr *array, gfc_exp

            /* Fall through.  */

-           case AR_SECTION:
            case AR_UNKNOWN:
              return NULL;
            }
Comment 4 Thomas Koenig 2009-01-26 09:14:27 UTC
> Here's a tentative patch:

... which causes regressions.

Back to the drawing board.
 
Comment 5 Thomas Koenig 2009-01-26 21:04:51 UTC
Created attachment 17186 [details]
patch

Here's something that at least passes all the *bound* tests.
Comment 6 Thomas Koenig 2009-01-26 22:50:32 UTC
> Here's something that at least passes all the *bound* tests.

Regression test passed - formal submission of the patch tomorrow,
probably. 

Comment 7 Thomas Koenig 2009-02-21 22:25:24 UTC
Subject: Bug 38914

Author: tkoenig
Date: Sat Feb 21 22:25:06 2009
New Revision: 144362

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144362
Log:
2008-02-21  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/38914
	* array.c (ref_dimen_size):  Rename to gfc_ref_dimen_size,
	make global.  Change function name in error messages.
	(ref_size):  Change ref_dimen_size to gfc_ref_dimen_size.
	(gfc_array_ref_shape):  Likewise.
	* gfortran.h:  Add prototype for gfc_ref_dimen_size.
	* simplify.c (simplify_bound_dim):  Add ref argument.
	If the reference isn't a full array, return one for
	the lower bound and the extent for the upper bound.
	(simplify_bound):  For array sections, take as from the
	argument.  Add reference to all to simplify_bound_dim.

2008-02-21  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/38914
	* bound_simplification_2.f90:  New test case.
	* bound_7.f90:  New test case.


Added:
    trunk/gcc/testsuite/gfortran.dg/bound_7.f90
    trunk/gcc/testsuite/gfortran.dg/bound_simplification_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/array.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/simplify.c
    trunk/gcc/testsuite/ChangeLog

Comment 8 Thomas Koenig 2009-06-07 14:39:02 UTC
I don't want to do any backport to 4.3 any more.

Closing.