------- Comment #2 from paul dot richard dot thomas at cea dot fr 2006-04-12 14:32 ------- (In reply to comment #1) > Confirmed, PR 25669 and bug 18003 are very closely related (it might turn out > this is a dup of one of them).
They are indeed the same. Attached below is a patch that fixes all three and a testcase that demonstrates that this is so. The patch is still testing but I am pretty sure it is OK (ie. this is a path that ICEd previously). I will submit tonight, if all is well. Paul Index: gcc/fortran/trans-array.c =================================================================== --- gcc/fortran/trans-array.c (révision 112853) +++ gcc/fortran/trans-array.c (copie de travail) @@ -2393,6 +2393,19 @@ loop->dimen = ss->data.info.dimen; break; + /* Cope with the likes of PRINT *, lbound (a), where nothing + better is available. */ + case GFC_SS_INTRINSIC: + switch (ss->expr->value.function.isym->generic_id) + { + case GFC_ISYM_LBOUND: + case GFC_ISYM_UBOUND: + loop->dimen = ss->data.info.dimen; + + default: + break; + } + default: break; } @@ -2418,6 +2431,15 @@ gfc_conv_section_startstride (loop, ss, n); break; + case GFC_SS_INTRINSIC: + switch (ss->expr->value.function.isym->generic_id) + { + case GFC_ISYM_LBOUND: + case GFC_ISYM_UBOUND: + break; + default: + continue; + } case GFC_SS_CONSTRUCTOR: case GFC_SS_FUNCTION: for (n = 0; n < ss->data.info.dimen; n++) Index: gcc/fortran/trans-intrinsic.c =================================================================== --- gcc/fortran/trans-intrinsic.c (révision 112853) +++ gcc/fortran/trans-intrinsic.c (copie de travail) @@ -3710,6 +3710,7 @@ newss->type = GFC_SS_INTRINSIC; newss->expr = expr; newss->next = ss; + newss->data.info.dimen = 1; return newss; } ! { dg-do compile } ! This tests the fix for PRs 26834, 25669 and 18803, in which ! shape information for the lbound and ubound intrinsics was not ! transferred to the scalarizer. For this reason, an ICE would ! ensue, whenever these functions were used in temporaries. ! ! The tests are lifted from the PRs and some further checks are ! done to make sure that nothing is broken. ! ! This is PR26834 subroutine gfcbug34 () implicit none type t integer, pointer :: i (:) => NULL () end type t type(t), save :: gf allocate (gf%i(20)) write(*,*) 'ubound:', ubound (gf% i) write(*,*) 'lbound:', lbound (gf% i) end subroutine gfcbug34 ! This is PR25669 subroutine foo (a) real a(*) call bar (a, LBOUND(a),2) end subroutine foo subroutine bar (b, i, j) real b(i:j) print *, i, j print *, b(i:j) end subroutine bar ! This is PR18003 subroutine io_bug() integer :: a(10) print *, ubound(a) end subroutine io_bug ! This checks that lbound and ubound are OK in temporary ! expressions. subroutine io_bug_plus() integer :: a(10, 10), b(2) print *, ubound(a)*(/1,2/) print *, (/1,2/)*ubound(a) end subroutine io_bug_plus character(4) :: ch(2), ech(2) = (/'ABCD', 'EFGH'/) real(4) :: a(2) equivalence (ech,a) integer(1) :: i(8) = (/(j, j = 1,8)/) ! Check that the bugs have gone call io_bug () call io_bug_plus () call foo ((/1.0,2.0,3.0/)) call gfcbug34 () ! Check that we have not broken other intrinsics. print *, cos ((/1.0,2.0/)) print *, transfer (a, ch) print *, i(1:4) * transfer (a, i, 4) * 2 end -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26834