public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] PR fortran/37749 ICE on array section with vector  subscript
@ 2008-10-31  0:53 Mikael Morin
  2008-10-31 11:28 ` Paul Richard Thomas
  0 siblings, 1 reply; 2+ messages in thread
From: Mikael Morin @ 2008-10-31  0:53 UTC (permalink / raw)
  To: correctifs gcc, gfortran

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

Hello,

here comes the e-mail version of my patch posted on bugzilla:
with a ChangeLog entry and the testcase.

As a reminder, this patch looks for a NULL loop->to[n] before setting
the temporary descriptor to check whether we are using a
callee-allocated array or not.
This prevents setting the descriptor with a NULL size (which segfaults).

I didn't take the run-time check from the original testcase, as it is
just a compilation failure.

regression tested on x86_64-unknown-linux-gnu.

Mikael


2008-10-30  Mikael Morin  <mikael.morin@tele2.fr>

	PR fortran/37749
	* trans-array.c (gfc_trans_create_temp_array): Check whether
	there is one NULL loop->to[n] before setting the descriptor
	with the loop bounds.

2008-10-30  Mikael Morin  <mikael.morin@tele2.fr>

	PR fortran/37749
	* gfortran.dg/vector_subscript_4.f90: New test.

[-- Attachment #2: pr37749_06.diff --]
[-- Type: text/plain, Size: 1909 bytes --]

Index: gcc/testsuite/gfortran.dg/vector_subscript_4.f90
===================================================================
--- gcc/testsuite/gfortran.dg/vector_subscript_4.f90	(révision 0)
+++ gcc/testsuite/gfortran.dg/vector_subscript_4.f90	(révision 0)
@@ -0,0 +1,21 @@
+! { dg-do compile }
+!
+! PR fortran/37749
+! ICE on array section with vector subscript
+!
+! Modified testcase from Jakub Jelinek <jakub@gcc.gnu.org>
+!
+subroutine subr (m, n, a, b, c, d, p)
+  implicit none
+  integer m, n
+  real a(m,n), b(m,n), c(n,n), d(m,n)
+  integer p(n), q(m)
+  d = a(:,p) - matmul(b, c)     ! Original case
+  d = a(q,:) - matmul(b, c)     ! Other cases are there because order matters
+  d = a(:,:) - matmul(b, c)
+  d = a(q,p) - matmul(b, c)
+  d = matmul(b, c) - a(:,p)
+  d = matmul(b, c) - a(q,:)
+  d = matmul(b, c) - a(:,:)
+  d = matmul(b, c) - a(q,p)
+end subroutine
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c	(révision 141460)
+++ gcc/fortran/trans-array.c	(copie de travail)
@@ -642,9 +642,18 @@ gfc_trans_create_temp_array (stmtblock_t * pre, st
 
   or_expr = NULL_TREE;
 
+  /* If there is at least one null loop->to[n], it is a callee allocated 
+     array.  */
   for (n = 0; n < info->dimen; n++)
+    if (loop->to[n] == NULL_TREE)
+      {
+	size = NULL_TREE;
+	break;
+      }
+
+  for (n = 0; n < info->dimen; n++)
     {
-      if (loop->to[n] == NULL_TREE)
+      if (size == NULL_TREE)
         {
 	  /* For a callee allocated array express the loop bounds in terms
 	     of the descriptor fields.  */
@@ -653,7 +662,6 @@ gfc_trans_create_temp_array (stmtblock_t * pre, st
 			 gfc_conv_descriptor_ubound (desc, gfc_rank_cst[n]),
 			 gfc_conv_descriptor_lbound (desc, gfc_rank_cst[n]));
           loop->to[n] = tmp;
-          size = NULL_TREE;
           continue;
         }
         

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

* Re: [Patch, Fortran] PR fortran/37749 ICE on array section with vector subscript
  2008-10-31  0:53 [Patch, Fortran] PR fortran/37749 ICE on array section with vector subscript Mikael Morin
@ 2008-10-31 11:28 ` Paul Richard Thomas
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Richard Thomas @ 2008-10-31 11:28 UTC (permalink / raw)
  To: Mikael Morin; +Cc: correctifs gcc, gfortran

Mikael,

I took action last night on this and PR37903 because I was concerned
that we were going to run out of time on stage 3.  I'm sorry about
doubling up our effort.  I tried to contact you before the commit but
failed.  If you have any problem with what I committed, please get in
touch and we will put it right.  You have been attributed in the
ChangeLogs:-)

Cheers

Paul

On Thu, Oct 30, 2008 at 8:44 PM, Mikael Morin <mikael.morin@tele2.fr> wrote:
> Hello,
>
> here comes the e-mail version of my patch posted on bugzilla:
> with a ChangeLog entry and the testcase.
>
> As a reminder, this patch looks for a NULL loop->to[n] before setting
> the temporary descriptor to check whether we are using a
> callee-allocated array or not.
> This prevents setting the descriptor with a NULL size (which segfaults).
>
> I didn't take the run-time check from the original testcase, as it is
> just a compilation failure.
>
> regression tested on x86_64-unknown-linux-gnu.
>
> Mikael
>
>
> 2008-10-30  Mikael Morin  <mikael.morin@tele2.fr>
>
>        PR fortran/37749
>        * trans-array.c (gfc_trans_create_temp_array): Check whether
>        there is one NULL loop->to[n] before setting the descriptor
>        with the loop bounds.
>
> 2008-10-30  Mikael Morin  <mikael.morin@tele2.fr>
>
>        PR fortran/37749
>        * gfortran.dg/vector_subscript_4.f90: New test.
>



-- 
The knack of flying is learning how to throw yourself at the ground and miss.
       --Hitchhikers Guide to the Galaxy

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

end of thread, other threads:[~2008-10-31  9:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-31  0:53 [Patch, Fortran] PR fortran/37749 ICE on array section with vector subscript Mikael Morin
2008-10-31 11:28 ` Paul Richard Thomas

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