This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH,committed] Fix PR Fortran 82841
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Wed, 8 Nov 2017 14:59:29 -0800
- Subject: [PATCH,committed] Fix PR Fortran 82841
- Authentication-results: sourceware.org; auth=none
- Reply-to: sgk at troutmask dot apl dot washington dot edu
Committed as obvious. ChangeLog explains change.
2017-11-08 Steven G. Kargl <kargl@kgcc.gnu.org>
PR Fortran/82841
* simplify.c(gfc_simplify_transfer): Do not dereference a NULL pointer.
Unwrap a short line.
2017-11-08 Steven G. Kargl <kargl@kgcc.gnu.org>
PR Fortran/82841
* gfortran.dg/transfer_simplify_11.f90: new test.
Index: gcc/fortran/simplify.c
===================================================================
--- gcc/fortran/simplify.c (revision 254552)
+++ gcc/fortran/simplify.c (working copy)
@@ -6576,8 +6576,7 @@ gfc_simplify_transfer (gfc_expr *source, gfc_expr *mol
return NULL;
/* Calculate the size of the source. */
- if (source->expr_type == EXPR_ARRAY
- && !gfc_array_size (source, &tmp))
+ if (source->expr_type == EXPR_ARRAY && !gfc_array_size (source, &tmp))
gfc_internal_error ("Failure getting length of a constant array.");
/* Create an empty new expression with the appropriate characteristics. */
@@ -6585,7 +6584,7 @@ gfc_simplify_transfer (gfc_expr *source, gfc_expr *mol
&source->where);
result->ts = mold->ts;
- mold_element = mold->expr_type == EXPR_ARRAY
+ mold_element = (mold->expr_type == EXPR_ARRAY && mold->value.constructor)
? gfc_constructor_first (mold->value.constructor)->expr
: mold;
Index: gcc/testsuite/gfortran.dg/transfer_simplify_11.f90
===================================================================
--- gcc/testsuite/gfortran.dg/transfer_simplify_11.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/transfer_simplify_11.f90 (working copy)
@@ -0,0 +1,8 @@
+! { dg-do run }
+! PR Fortran/82841
+!
+ integer, parameter :: N = 2
+ character(len=1) :: chr(N)
+ chr = transfer(repeat("x",ncopies=N),[character(len=1) ::], N)
+ if (chr(1) /= 'x' .and. chr(2) /= 'x') call abort
+end
--
Steve