public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andre Vehreschild <vehre@gmx.de>
To: Paul Richard Thomas <paul.richard.thomas@gmail.com>
Cc: "Dominique d'Humières" <dominiq@lps.ens.fr>,
	gcc-patches <gcc-patches@gcc.gnu.org>,
	"Mikael Morin" <mikael.morin@sfr.fr>,
	"GNU GFortran" <fortran@gcc.gnu.org>
Subject: Re: [Patch, Fortran, 66927, v2.1] [6 Regression] ICE in gfc_conf_procedure_call
Date: Mon, 26 Oct 2015 10:03:00 -0000	[thread overview]
Message-ID: <20151026110314.29862118@vepi2> (raw)
In-Reply-To: <20151025133102.2aa5ebd6@vepi2>

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

Hi all,

unfortunately did my last patch create a segfault on some 32-bit
system. This happens because in the scalarizer the lower bound of the
deferred length array of the source= expression was taken to be
constant zero instead of taking that information from the array
descriptor. This patch fixes the segfault by taking the lower -- and to
keep it in sync also the upper -- bound from the array descriptor when
doing the array assign in the allocate (). 

Bootstrapped and regtested on x86_64-linux-gnu/f21.

Ok for trunk?

Sorry for the regression.

Regards,
	Andre

On Sun, 25 Oct 2015 13:31:02 +0100
Andre Vehreschild <vehre@gmx.de> wrote:

> Hi Paul, hi all,
> 
> thanks for the review. Submitted as r229294.
> 
> Regards,
> 	Andre
> 
> On Sun, 25 Oct 2015 08:43:24 +0100
> Paul Richard Thomas <paul.richard.thomas@gmail.com> wrote:
> 
> > Dear Andre,
> > 
> > As far as I can see, the problems with PR57117 are specific to RESHAPE
> > and need not affect committing your patch. To my surprise, the
> > combination of your patch and mine for PR67171 fixes PR67044 in that
> > the ICE no longer occurs. I have to get my head around how to write a
> > testcase for it that tests the functionality though!
> > 
> > You can commit this patch to trunk. As I said elsewhere, I will rename
> > the testcase for PR67171.
> > 
> > Many thanks for the patch.
> > 
> > Paul
> > 
> > On 23 October 2015 at 09:44, Paul Richard Thomas
> > <paul.richard.thomas@gmail.com> wrote:
> > > Dear Andre,
> > >
> > > I will wait until you fix the problems that Dominique has pointed out.
> > > However, if by Sunday afternoon (rain forecast!) you haven't found the
> > > time, I will see if I can locate the source of these new problems.
> > >
> > > With best regards
> > >
> > > Paul
> > >
> > > On 7 October 2015 at 19:51, Dominique d'Humières <dominiq@lps.ens.fr> wrote:
> > >> This patch also fixes pr57117 comment 2, the original test and the test in comment 3 now give an ICE
> > >>
> > >> pr57117.f90:82:0:
> > >>
> > >>    allocate(z(9), source=reshape(x, (/ 9 /)))
> > >> 1
> > >> internal compiler error: Segmentation fault: 11
> > >>
> > >> and pr67044.
> > >>
> > >> Thanks,
> > >>
> > >> Dominique
> > >>
> > >
> > >
> > >
> > > --
> > > Outside of a dog, a book is a man's best friend. Inside of a dog it's
> > > too dark to read.
> > >
> > > Groucho Marx
> > 
> > 
> > 
> 
> 


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 

[-- Attachment #2: pr66927_3.clog --]
[-- Type: application/octet-stream, Size: 389 bytes --]

gcc/fortran/ChangeLog:

2015-10-26  Andre Vehreschild  <vehre@gmx.de>

	* trans-array.c (evaluate_bound): For deferred length arrays get the
	bounds directly from the descriptor, i.e., prevent using constant
	zero lower bound from the gfc_conv_array_lbound () routine.
	(gfc_conv_section_startstride): Hand deferred array status to
	evaluate_bound ().
	(gfc_conv_expr_descriptor): Same.



[-- Attachment #3: pr66927_3.patch --]
[-- Type: text/x-patch, Size: 2416 bytes --]

diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index b726998..f6e980d 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -3809,7 +3809,7 @@ gfc_trans_scalarized_loop_boundary (gfc_loopinfo * loop, stmtblock_t * body)
 
 static void
 evaluate_bound (stmtblock_t *block, tree *bounds, gfc_expr ** values,
-		tree desc, int dim, bool lbound)
+		tree desc, int dim, bool lbound, bool deferred)
 {
   gfc_se se;
   gfc_expr * input_val = values[dim];
@@ -3824,6 +3824,17 @@ evaluate_bound (stmtblock_t *block, tree *bounds, gfc_expr ** values,
       gfc_add_block_to_block (block, &se.pre);
       *output = se.expr;
     }
+  else if (deferred)
+    {
+      /* The gfc_conv_array_lbound () routine returns a constant zero for
+	 deferred length arrays, which in the scalarizer wrecks havoc, when
+	 copying to a (newly allocated) one-based array.
+	 Keep returning the actual result in sync for both bounds.  */
+      *output = lbound ? gfc_conv_descriptor_lbound_get (desc,
+							 gfc_rank_cst[dim]):
+			 gfc_conv_descriptor_ubound_get (desc,
+							 gfc_rank_cst[dim]);
+    }
   else
     {
       /* No specific bound specified so use the bound of the array.  */
@@ -3864,14 +3875,18 @@ gfc_conv_section_startstride (stmtblock_t * block, gfc_ss * ss, int dim)
   desc = info->descriptor;
   stride = ar->stride[dim];
 
+
   /* Calculate the start of the range.  For vector subscripts this will
      be the range of the vector.  */
-  evaluate_bound (block, info->start, ar->start, desc, dim, true);
+  evaluate_bound (block, info->start, ar->start, desc, dim, true,
+		  ar->as->type == AS_DEFERRED);
 
   /* Similarly calculate the end.  Although this is not used in the
      scalarizer, it is needed when checking bounds and where the end
      is an expression with side-effects.  */
-  evaluate_bound (block, info->end, ar->end, desc, dim, false);
+  evaluate_bound (block, info->end, ar->end, desc, dim, false,
+		  ar->as->type == AS_DEFERRED);
+
 
   /* Calculate the stride.  */
   if (stride == NULL)
@@ -6965,7 +6980,8 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *expr)
 
 	  gcc_assert (n == codim - 1);
 	  evaluate_bound (&loop.pre, info->start, ar->start,
-			  info->descriptor, n + ndim, true);
+			  info->descriptor, n + ndim, true,
+			  ar->as->type == AS_DEFERRED);
 	  loop.from[n + loop.dimen] = info->start[n + ndim];
 	}
       else

  reply	other threads:[~2015-10-26 10:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-25  7:43 [Patch, Fortran, 66927, v2] " Paul Richard Thomas
2015-10-25 12:31 ` Andre Vehreschild
2015-10-26 10:03   ` Andre Vehreschild [this message]
2015-10-26 12:04     ` [Patch, Fortran, 66927, v2.1] " Paul Richard Thomas
2015-10-26 13:04       ` Andre Vehreschild

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151026110314.29862118@vepi2 \
    --to=vehre@gmx.de \
    --cc=dominiq@lps.ens.fr \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mikael.morin@sfr.fr \
    --cc=paul.richard.thomas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).