* [Patch, fortran] PR fortran/96726 - ICE with user defined specification function on assumed-rank array
@ 2020-08-20 17:49 José Rui Faustino de Sousa
2020-08-22 10:24 ` Thomas Koenig
0 siblings, 1 reply; 2+ messages in thread
From: José Rui Faustino de Sousa @ 2020-08-20 17:49 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 585 bytes --]
Hi all!
Proposed patch to PR96726 - ICE with user defined specification function
on assumed-rank array.
Patch tested only on x86_64-pc-linux-gnu.
Obvious fix, replace different operator with less than to avoid infinite
loop.
Thank you very much.
Best regards,
José Rui
2020-8-20 José Rui Faustino de Sousa <jrfsousa@gmail.com>
PR fortran/96726
* expr.c (check_references): Change different relational operator to
less-than operator to avoid infinite loop.
2020-8-20 José Rui Faustino de Sousa <jrfsousa@gmail.com>
PR fortran/96726
* PR96726.f90: New test.
[-- Attachment #2: PR96726.patch --]
[-- Type: text/x-patch, Size: 1761 bytes --]
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 6707ca5..2ef01f0 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -3273,7 +3273,7 @@ check_references (gfc_ref* ref, bool (*checker) (gfc_expr*))
switch (ref->type)
{
case REF_ARRAY:
- for (dim = 0; dim != ref->u.ar.dimen; ++dim)
+ for (dim = 0; dim < ref->u.ar.dimen; ++dim)
{
if (!checker (ref->u.ar.start[dim]))
return false;
diff --git a/gcc/testsuite/gfortran.dg/PR96726.f90 b/gcc/testsuite/gfortran.dg/PR96726.f90
new file mode 100644
index 0000000..b0b26b9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/PR96726.f90
@@ -0,0 +1,72 @@
+! { dg-do run }
+!
+! Test the fix for PR96726
+!
+
+module cref_m
+
+ implicit none
+
+ private
+
+ public :: &
+ sizeish
+
+contains
+
+ pure function sizeish(a) result(s)
+ integer, intent(in) :: a(..)
+
+ integer :: s
+
+ s = size(a)
+ return
+ end function sizeish
+
+end module cref_m
+
+program cref_p
+
+ use cref_m, only: &
+ sizeish
+
+ implicit none
+
+ integer :: i
+
+ integer, parameter :: n = 3
+ integer, parameter :: p(*) = [(i, i=1,n*n)]
+
+ integer :: a(n,n)
+ integer :: b(n*n)
+
+ a = reshape(p, shape=[n,n])
+ call isub_a(a, b)
+ if (any(b/=p)) stop 1
+ call isub_b(a, b)
+ if (any(b/=p)) stop 2
+ stop
+
+contains
+
+ subroutine isub_a(a, b)
+ integer, intent(in) :: a(..)
+ integer, intent(out) :: b(size(a))
+
+ integer :: i
+
+ b = [(i, i=1,size(b))]
+ return
+ end subroutine isub_a
+
+ subroutine isub_b(a, b)
+ integer, intent(in) :: a(..)
+ integer, intent(out) :: b(sizeish(a))
+
+ integer :: i
+
+ b = [(i, i=1,sizeish(b))]
+ return
+ end subroutine isub_b
+
+end program cref_p
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Patch, fortran] PR fortran/96726 - ICE with user defined specification function on assumed-rank array
2020-08-20 17:49 [Patch, fortran] PR fortran/96726 - ICE with user defined specification function on assumed-rank array José Rui Faustino de Sousa
@ 2020-08-22 10:24 ` Thomas Koenig
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Koenig @ 2020-08-22 10:24 UTC (permalink / raw)
To: José Rui Faustino de Sousa, fortran, gcc-patches
Hi Jose,
> Proposed patch to PR96726 - ICE with user defined specification function
> on assumed-rank array.
OK, you'll need a to work on the ChangeLog format to commit this
(like I wrote in my previous mail).
Thanks for the patch!
Regards
Thomas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-22 10:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-20 17:49 [Patch, fortran] PR fortran/96726 - ICE with user defined specification function on assumed-rank array José Rui Faustino de Sousa
2020-08-22 10:24 ` Thomas Koenig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).