This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, fortran] PR15809 (PR19276) - ICE and segfault with automa tic character, dummy pointer arrays


On Mon, Nov 28, 2005 at 05:33:41PM +0100, THOMAS Paul Richard 169137 wrote:
> :ADDPATCH fortran:

:REVIEWMAIL:

> This patch fixes PR15809 and the problem that Toon notified to the list last
> night. This is the last of the unfixed problems in the character meta-bug
> PR19276 (I note that I have not committed the other two fixes to gcc-4.1; I
> will do so in the next 24hours.)
> 
> There are three elements:
> 
> 1] The fix to the problem that Toon notified is in trans-io.c; around the
> gcc-assert that caused the ICE.  The problem is that 
> 
> tmp = gfc_get_dtype (TREE_TYPE (se.expr));
> if (((TREE_INT_CST_LOW (tmp) & GFC_DTYPE_TYPE_MASK) 
>         >> GFC_DTYPE_TYPE_SHIFT) != GFC_DTYPE_DERIVED)
> 
> is not compatible with the case, where the dtype is an expression.  This,
> slightly unusual situation occurs with automatic character length arrays.
> The solution is to use the references in the gfc_expr to generate the
> condition.  This has the advantage that a descriptor is not generated, so
> that no clean-up is necessary for the cases in which a descriptor cannot be
> passed.

Thanks, it's a bit cleaner than my original version. See a few
comments in the patch though.

> 2] The second element is the incomplete PR15809 fix proposed by Erik
> Edelmann that allows both VAR_DECLs and PARM_DECLs to go through
> trans-array.c(gfc_trans_deferred_array ).  This stops the ICEs on references
> to the offending variables that do not need any size information.

This is OK I guess.

> 3] The final bit of the puzzle is to attach the character length onto the
> dtype. This has been done by setting the TYPE_SIZE_UNIT of the array
> elements in trans-decl.c(gfc_get_symbol_decl). This works because the
> evaluation of the expression for the dtype occurs in the function code.
> Leaving this step until gfc_trans_deferred_array does work correctly, as far
> as I could assertain, but leaves some alarming dtype assignements that do
> not contain a size.

Actually, I'm not sure this is what we want to do. The problem is that
there's only 24 bits in the dtype for the length, so it breaks for
bigger character variables. There was some PR:s about this, and a
number of intrinsics as well as transfer_array were rewritten to take
an extra argument for the string length instead of using the
descriptor. Or perhaps I misunderstood what this part of the patch
does?


Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c    (révision 107541)
+++ gcc/fortran/trans-decl.c    (copie de travail)
@@ -845,6 +845,26 @@
              if (TREE_CODE (length) != INTEGER_CST)
                {
                  gfc_finish_var_decl (length, sym);
+
+                 /* Set the element size of automatic character length
+                    length, dummy, pointer arrays.  */

Typo (length*2)?

> Index: gcc/fortran/trans-io.c
> ===================================================================
> --- gcc/fortran/trans-io.c	(révision 107541)
> +++ gcc/fortran/trans-io.c	(copie de travail)
> @@ -1788,33 +1790,25 @@
>      }
>    else
>      {
> -      /* Transfer an array. There are 3 options:
> -      1) An array of an intrinsic type. This is handled by transfering
> -	 the descriptor to the library.
> -      2) A derived type containing an array. Scalarized by the frontend.
> -      3) An array of derived type. Scalarized by the frontend.
> -      */
> -      if (expr->ts.type != BT_DERIVED)
> +      /* Transfer an array. If it is an array of an intrinsic
> +	 type, whether a derived type component or not, pass
> +	 the descriptor to the library.  Otherwise scalarize
> +	 the transfer.  */

This comment is not correct. If an intrinsic is a derived type
component, it is scalarized, even with this patch.

And yes, the updated testcase you sent by private mail works correctly
on Linux.


-- 
Janne Blomqvist

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]