diff mbox series

[fortran] PR fortran/95352 - ICE on select rank with assumed-size selector and lbound intrinsic

Message ID 223fb438-cef3-6772-5964-f888be290e3b@gmail.com
State New
Headers show
Series [fortran] PR fortran/95352 - ICE on select rank with assumed-size selector and lbound intrinsic | expand

Commit Message

José Rui Faustino de Sousa Aug. 21, 2020, 10:29 a.m. UTC
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 <sgk@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  <jrfsousa@gmail.com>

  PR fortran/95352
  * PR95352.f90: New test.

Comments

Thomas Koenig Aug. 21, 2020, 6:15 p.m. UTC | #1
Hi Jose,

> 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.

this is OK, but you'll have to adjust your ChangeLog.

I'll only write this once for your series of patches
(I think you just broke the record for most patches per day :-)

Regarding the ChangeLog, for this and for your other patches:
Before this is accepted by the scripts, you will need to massage
the git commit log into a form for that the scripts will accept.

You can run your commit through "git gcc-verify" to check
if you have previously run contrib/gcc-git-customization.sh
(which I recommend). Read

https://gcc.gnu.org/codingconventions.html#ChangeLogs

to find the gory details.  Running contrib/mklog.py will
prepare a template for the ChangeLog.

Thanks a lot for taking up this patch!

Best regards

	Thomas
diff mbox series

Patch

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