Bug 40604 - ICE with -fcheck=pointer
Summary: ICE with -fcheck=pointer
Status: RESOLVED DUPLICATE of bug 40605
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2009-07-01 12:01 UTC by janus
Modified: 2009-07-01 13:02 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description janus 2009-07-01 12:01:09 UTC
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
Comment 1 janus 2009-07-01 12:13:26 UTC
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)
Comment 2 Tobias Burnus 2009-07-01 13:02:47 UTC
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 ***
Comment 3 Tobias Burnus 2009-07-09 09:42:50 UTC
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