Committed as obvious. ChangeLog explains change. 2017-11-08 Steven G. Kargl <ka...@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 <ka...@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