Hi all!
Proposed patch to PR95352 - ICE on select rank with assumed-size
selector and lbound intrinsic.
Patch tested only on x86_64-pc-linux-gnu.
Add check for NULL pointer before trying to access structure member,
patch by Steve Kargl.
Thank you very much.
Best regards,
José Rui
2020-8-21 Steve Kargl <s...@troutmask.apl.washington.edu>
PR fortran/95352
* simplify.c (simplify_bound_dim): Add check for NULL pointer before
trying to access structure member.
2020-8-21 José Rui Faustino de Sousa <jrfso...@gmail.com>
PR fortran/95352
* PR95352.f90: New test.
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 074b50c..a1153dd 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -4080,7 +4080,7 @@ simplify_bound_dim (gfc_expr *array, gfc_expr *kind, int d, int upper,
|| (coarray && d == as->rank + as->corank
&& (!upper || flag_coarray == GFC_FCOARRAY_SINGLE)))
{
- if (as->lower[d-1]->expr_type == EXPR_CONSTANT)
+ if (as->lower[d-1] && as->lower[d-1]->expr_type == EXPR_CONSTANT)
{
gfc_free_expr (result);
return gfc_copy_expr (as->lower[d-1]);
diff --git a/gcc/testsuite/gfortran.dg/PR95352.f90 b/gcc/testsuite/gfortran.dg/PR95352.f90
new file mode 100644
index 0000000..20c8167
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/PR95352.f90
@@ -0,0 +1,27 @@
+! { dg-do compile }
+!
+! Test the fix for PR95352
+!
+
+module ice6_m
+
+ implicit none
+
+contains
+
+ function ice6_s(a) result(ierr)
+ integer, intent(in) :: a(..)
+
+ integer :: ierr
+
+ integer :: lb
+
+ select rank(a)
+ rank(*)
+ lb = lbound(a, dim=1)
+ if(lbound(a, dim=1)/=lb) ierr = -1
+ end select
+ return
+ end function ice6_s
+
+end module ice6_m