The following code gives an ICE when compiled with -fcheck-pointer: call test(uec=-1) contains subroutine test(str,uec) implicit none character*(*), intent(in), optional:: str integer, intent(in), optional :: uec end subroutine end
Patch: Index: gcc/fortran/trans-expr.c =================================================================== --- gcc/fortran/trans-expr.c (revision 149129) +++ gcc/fortran/trans-expr.c (working copy) @@ -2781,6 +2781,9 @@ gfc_conv_procedure_call (gfc_se * se, gf char *msg; tree cond; + if (e == NULL) + goto end_pointer_check; + if (e->expr_type == EXPR_VARIABLE) sym = e->symtree->n.sym; else if (e->expr_type == EXPR_FUNCTION)
Yours was there first, but still I make it as duplicate of my PR. Note there is also a fix needed for the run-time check, also due to OPTIONAL. Thanks for the report. *** This bug has been marked as a duplicate of 40605 ***
Subject: Bug 40604 Author: burnus Date: Thu Jul 9 09:42:34 2009 New Revision: 149405 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149405 Log: 2009-07-09 Tobias Burnus <burnus@net-b.de> PR fortran/40604 * intrinsic.c (gfc_convert_type_warn): Set sym->result. * trans-expr.c (gfc_conv_procedure_call): Fix -fcheck=pointer for optional arguments. 2009-07-09 Tobias Burnus <burnus@net-b.de> PR fortran/40604 * gfortran.dg/pointer_check_6.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/pointer_check_6.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/intrinsic.c trunk/gcc/fortran/trans-expr.c trunk/gcc/testsuite/ChangeLog