From 8c727bdf4acf28c8315b119a1c8f6d6af745c2af Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Thu, 4 Jun 2020 21:00:33 +0200 Subject: [PATCH] PR fortran/95500 - Segfault compiling extra interface on intrinsic Converting an expression so that it can be passed by reference could result in a NULL pointer dereference. 2020-06-04 Steven G. Kargl Harald Anlauf gcc/fortran/ PR fortran/95500 * trans-expr.c (gfc_conv_expr_reference): Do not dereference NULL pointer. gcc/testsuite/ PR fortran/95500 * gfortran.dg/pr95500.f90: New test. --- gcc/fortran/trans-expr.c | 1 + gcc/testsuite/gfortran.dg/pr95500.f90 | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr95500.f90 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 435eaeb2c99..8b2afd27fb3 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -8811,6 +8811,7 @@ gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr, bool add_clobber) if (expr->expr_type == EXPR_FUNCTION && ((expr->value.function.esym + && expr->value.function.esym->result && expr->value.function.esym->result->attr.pointer && !expr->value.function.esym->result->attr.dimension) || (!expr->value.function.esym && !expr->ref diff --git a/gcc/testsuite/gfortran.dg/pr95500.f90 b/gcc/testsuite/gfortran.dg/pr95500.f90 new file mode 100644 index 00000000000..e9eb7c65c86 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr95500.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! PR fortran/95500 - ICE compiling extra interface on intrinsic + +program test_intrinsic + implicit none + intrinsic :: alog + intrinsic :: dlog + real (4), parameter :: one = 1 + + interface ln + procedure :: alog, dlog + end interface ln + + write (*,*) 'ln 1', ln (one) +end program test_intrinsic -- 2.30.2