Commit 4b3ea558 by Harald Anlauf

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  <kargl@gcc.gnu.org>
	    Harald Anlauf  <anlauf@gmx.de>

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.

(cherry picked from commit 8c727bdf4acf28c8315b119a1c8f6d6af745c2af)
parent 27e98547
...@@ -8810,6 +8810,7 @@ gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr, bool add_clobber) ...@@ -8810,6 +8810,7 @@ gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr, bool add_clobber)
if (expr->expr_type == EXPR_FUNCTION if (expr->expr_type == EXPR_FUNCTION
&& ((expr->value.function.esym && ((expr->value.function.esym
&& expr->value.function.esym->result
&& expr->value.function.esym->result->attr.pointer && expr->value.function.esym->result->attr.pointer
&& !expr->value.function.esym->result->attr.dimension) && !expr->value.function.esym->result->attr.dimension)
|| (!expr->value.function.esym && !expr->ref || (!expr->value.function.esym && !expr->ref
......
! { 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment