public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR fortran/95352 - ICE on select rank with assumed-size selector and lbound intrinsic
@ 2020-08-21 10:29 José Rui Faustino de Sousa
  2020-08-21 18:15 ` Thomas Koenig
  0 siblings, 1 reply; 2+ messages in thread
From: José Rui Faustino de Sousa @ 2020-08-21 10:29 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 586 bytes --]

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.

[-- Attachment #2: PR95352.patch --]
[-- Type: text/x-patch, Size: 1169 bytes --]

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch, fortran] PR fortran/95352 - ICE on select rank with assumed-size selector and lbound intrinsic
  2020-08-21 10:29 [Patch, fortran] PR fortran/95352 - ICE on select rank with assumed-size selector and lbound intrinsic José Rui Faustino de Sousa
@ 2020-08-21 18:15 ` Thomas Koenig
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Koenig @ 2020-08-21 18:15 UTC (permalink / raw)
  To: José Rui Faustino de Sousa, fortran, gcc-patches

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-21 18:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21 10:29 [Patch, fortran] PR fortran/95352 - ICE on select rank with assumed-size selector and lbound intrinsic José Rui Faustino de Sousa
2020-08-21 18:15 ` 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).