I've committed the attached patch. It checks for a valid
pointer before using it.
2018-05-11 Steven G. Kargl <[email protected]>
PR fortran/85542
* expr.c (check_inquiry): Avoid NULL pointer dereference.
2018-05-11 Steven G. Kargl <[email protected]>
PR fortran/85542
* gfortran.dg/pr85542.f90: New test.
--
Steve
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c (revision 259653)
+++ gcc/fortran/expr.c (working copy)
@@ -2422,7 +2422,7 @@ check_inquiry (gfc_expr *e, int not_restricted)
/* Assumed character length will not reduce to a constant expression
with LEN, as required by the standard. */
- if (i == 5 && not_restricted
+ if (i == 5 && not_restricted && ap->expr->symtree
&& ap->expr->symtree->n.sym->ts.type == BT_CHARACTER
&& (ap->expr->symtree->n.sym->ts.u.cl->length == NULL
|| ap->expr->symtree->n.sym->ts.deferred))
Index: gcc/testsuite/gfortran.dg/pr85542.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr85542.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr85542.f90 (working copy)
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! PR fortran/85542
+function f(x)
+ character(*), intent(in) :: x
+ character((len((x)))) :: f
+ f = x
+end