[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 Thomas Koenig changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #19 from Thomas Koenig --- Fixed, closing.
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 --- Comment #18 from Thomas Koenig --- Author: tkoenig Date: Sun Mar 11 20:28:00 2018 New Revision: 258435 URL: https://gcc.gnu.org/viewcvs?rev=258435&root=gcc&view=rev Log: 2018-03-11 Thomas Koenig PR fortran/66128 * simplify.c (simplify_transformation): Return default result for empty array argument. (gfc_simplify_all): Remove special-case handling for zerosize. (gfc_simplify_any): Likewise. (gfc_simplify_count): Likewise. (gfc_simplify_iall): Likewise. (gfc_simplify_iany): Likewise. (gfc_simplify_iparity): Likewise. (gfc_simplify_minval): Likewise. (gfc_simplify_maxval): Likewise. (gfc_simplify_norm2): Likewise. (gfc_simplify_product): Likewise. (gfc_simplify_sum): Likewise. 2018-03-11 Thomas Koenig PR fortran/66128 * gfortran.dg/zero_sized_9.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/zero_sized_9.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/simplify.c trunk/gcc/testsuite/ChangeLog
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 --- Comment #17 from Thomas Koenig --- Here's a problem with maxval: $ cat maxval_parameter_2.f90 ! { dg-do run } program main integer, dimension(0,3), parameter :: i = 0 integer, dimension(0,3) :: j = 0 print *,maxval(i,dim=1) print *,maxval(j,dim=1) end program main $ gfortran maxval_parameter_2.f90 $ ./a.out -2147483648 -2147483648 -2147483648 -2147483648 The run-time result is correct, the simplified version isn't.
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 Thomas Koenig changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |tkoenig at gcc dot gnu.org --- Comment #16 from Thomas Koenig --- I'll take a look at what's left (maxval for strings, at least) and fix what is necessary to fix.
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 Bug 66128 depends on bug 84697, which changed state. Bug 84697 Summary: [8 Regression] minloc/maxloc not simplified with zero size https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84697 What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 --- Comment #15 from Thomas Koenig --- Author: tkoenig Date: Tue Mar 6 23:50:01 2018 New Revision: 258305 URL: https://gcc.gnu.org/viewcvs?rev=258305&root=gcc&view=rev Log: 2017-03-06 Thomas Koenig PR fortran/84697 PR fortran/66128 * expr.c (simplify_parameter_variable): If p is a size zero array and not an ARRAY_EXPR insert an empty array constructor and return. * gfortran.h: Add prototype for gfc_is_size_zero_array. * simplify.c (is_size_zero_array): Make non-static and rename into (gfc_is_size_zero_array): Check for parameter arrays of zero size by comparing shape and absence of constructor. (gfc_simplify_all): Use gfc_is_size_zero_array instead of is_size_zero_array. (gfc_simplify_count): Likewise. (gfc_simplify_iall): Likewise. (gfc_simplify_iany): Likewise. (gfc_simplify_iparity): Likewise. (gfc_simplify_minval): Likewise. (gfc_simplify_maxval): Likewise. (gfc_simplify_product): Likewise. (gfc_simplify_sum): Likewise. 2017-03-06 Thomas Koenig PR fortran/84697 PR fortran/66128 * gfortran.dg/minmaxloc_zerosize_1.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/minmaxloc_zerosize_1.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/expr.c trunk/gcc/fortran/gfortran.h trunk/gcc/fortran/simplify.c trunk/gcc/testsuite/ChangeLog
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 --- Comment #14 from kargl at gcc dot gnu.org --- (In reply to Thomas Koenig from comment #11) > According to your mail at (In reply to kargl from comment #10) > > > Closing as fixed. > > https://gcc.gnu.org/ml/fortran/2018-03/msg00010.html still shows a few > tests that fail. > > Let's keep this PR open to track these. First, I should note that the URL does not lead to a list of tests that fail. It points to a list of intrinsic subrprogram where the Fortran standard specifically calls out behavior for dummy arguments associated with a size zero actual argument. No tests were written or performed. Item 1) is covered by PR 54613 Item 2) is now PR 84697. Items 3)-5) do not exhibit any unexpected behavior. Item 6) concerns old g77 compatibility routines I won't check those as no one should be using these routines. This PR should be closed, but I'll leave that up to others.
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 Thomas Koenig changed: What|Removed |Added Status|SUSPENDED |NEW
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 kargl at gcc dot gnu.org changed: What|Removed |Added Assignee|kargl at gcc dot gnu.org |unassigned at gcc dot gnu.org --- Comment #13 from kargl at gcc dot gnu.org --- unassign myself
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 kargl at gcc dot gnu.org changed: What|Removed |Added Status|NEW |SUSPENDED --- Comment #12 from kargl at gcc dot gnu.org --- (In reply to Thomas Koenig from comment #11) > According to your mail at (In reply to kargl from comment #10) > > > Closing as fixed. > > https://gcc.gnu.org/ml/fortran/2018-03/msg00010.html still shows a few > tests that fail. > > Let's keep this PR open to track these. I was going to submit individual PR's for the remaining issues after writing code to actually test for the ICE.
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 Thomas Koenig changed: What|Removed |Added Status|RESOLVED|NEW CC||tkoenig at gcc dot gnu.org Resolution|FIXED |--- --- Comment #11 from Thomas Koenig --- According to your mail at (In reply to kargl from comment #10) > Closing as fixed. https://gcc.gnu.org/ml/fortran/2018-03/msg00010.html still shows a few tests that fail. Let's keep this PR open to track these.
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 kargl at gcc dot gnu.org changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED Target Milestone|--- |8.0 --- Comment #10 from kargl at gcc dot gnu.org --- Fixed on trunk. The patch does not apply cleaning to branch-7 due to changes in minval max maxval simplification changes. Closing as fixed. Thanks for the bug report.
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 --- Comment #9 from kargl at gcc dot gnu.org --- Author: kargl Date: Sat Mar 3 19:59:54 2018 New Revision: 258224 URL: https://gcc.gnu.org/viewcvs?rev=258224&root=gcc&view=rev Log: 2018-03-03 Steven G. Kargl PR fortran/66128 * gfortran.dg/zero_sized_8.f90: Really commit new test. Added: trunk/gcc/testsuite/gfortran.dg/zero_sized_8.f90 Modified: trunk/gcc/testsuite/ChangeLog
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 --- Comment #8 from kargl at gcc dot gnu.org --- Author: kargl Date: Sat Mar 3 19:49:20 2018 New Revision: 258223 URL: https://gcc.gnu.org/viewcvs?rev=258223&root=gcc&view=rev Log: 2018-03-03 Steven G. Kargl PR fortran/66128 * simplify.c (is_size_zero_array): New function to check for size zero array. (gfc_simplify_all, gfc_simplify_any, gfc_simplify_count, gfc_simplify_iall, gfc_simplify_iany, gfc_simplify_iparity, gfc_simplify_minval, gfc_simplify_maxval, gfc_simplify_norm2, gfc_simplify_product, gfc_simplify_sum): Use it, and implement requirements from F2018. 2018-03-03 Steven G. Kargl PR fortran/66128 * gfortran.dg/zero_sized_8.f90: New test. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/simplify.c trunk/gcc/testsuite/ChangeLog
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 --- Comment #7 from kargl at gcc dot gnu.org --- Patch submitted. https://gcc.gnu.org/ml/fortran/2018-03/msg00010.html This fixes additional failures not included in Gerhard's testcases.
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 --- Comment #6 from Steve Kargl --- I've worked out the issues with regression in the testsuite. (Well, I think I have.)
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 --- Comment #5 from Steve Kargl --- On Thu, Mar 01, 2018 at 10:31:42PM +, kargl at gcc dot gnu.org wrote: > (In reply to Harald Anlauf from comment #3) > > Maybe some kind of "shortcut" (similar to Steve's fix for pr83998) can > > solve this. Not sure where this would fit in. > > I have a patch for at least the ANY and ALL problem. :-) > Well, the simply obvious patch gfc_expr * gfc_simplify_any (gfc_expr *mask, gfc_expr *dim) { + /* Check for zero sized array. sgk */ + if (mask->rank > 0 && mask->shape == NULL) + return gfc_get_logical_expr (mask->ts.kind, &mask->where, false); + return simplify_transformation (mask, dim, NULL, false, gfc_or); } cause a bunch of regressions. One is given by ! { dg-do run } ! PR 71795 - wrong result when putting an array constructor ! instide an iterator. program test implicit none integer :: i,n logical, dimension(1) :: ra logical :: rs integer, allocatable :: a(:) allocate ( a(1) ) n = 1 a = 2 rs = any ( (/ (any(a(i).eq.(/1,2,3/)) ,i=1,n) /) ) if (.not. rs) call abort end program test which is odd. The code never goes through the if () statement as mask->shape is always non-null. So, the code should compile as-if I never made a change to gfc_simplify_any. :(
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 kargl at gcc dot gnu.org changed: What|Removed |Added Priority|P3 |P4 CC||kargl at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |kargl at gcc dot gnu.org --- Comment #4 from kargl at gcc dot gnu.org --- (In reply to Harald Anlauf from comment #3) > Maybe some kind of "shortcut" (similar to Steve's fix for pr83998) can > solve this. Not sure where this would fit in. I have a patch for at least the ANY and ALL problem. :-)
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 --- Comment #3 from Harald Anlauf --- Maybe some kind of "shortcut" (similar to Steve's fix for pr83998) can solve this. Not sure where this would fit in.
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 kargl at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2015-05-13 CC||kargl at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from kargl at gcc dot gnu.org --- Confirmed. I glance at the simplification code suggests that gfortran is not considering the possibility of zero-sized constant arrays. Not sure how to fix this one.
[Bug fortran/66128] ICE for some intrinsics with zero sized array parameter
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66128 --- Comment #1 from Gerhard Steinmetz --- Some more examples with other error messages. This one ... program p integer, parameter :: z(0) = 0 print *, count(z > 0) end yields : internal compiler error: in gfc_conv_intrinsic_count, at fortran/trans-intrinsic.c:3233 This one ... program p integer, parameter :: z(0) = 0 print *, iall(z, z > 0) print *, iany(z, z > 0) print *, iparity(z, z > 0) print *, parity(z > 0) print *, product(z, z > 0) print *, sum(z, z > 0) end yields : internal compiler error: in gfc_conv_intrinsic_arith, at fortran/trans-intrinsic.c:3357 This one ... program p integer, parameter :: z(0) = 0 print *, minval(z, z > 0) print *, maxval(z, z > 0) end yields : internal compiler error: in gfc_conv_intrinsic_minmaxval, at fortran/trans-intrinsic.c:4253