Bug 18600

Summary: ICE NIST FM020.f reduced case
Product: gcc Reporter: Jerry DeLisle <jvdelisle>
Component: fortranAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED WORKSFORME    
Severity: normal CC: fxcoudert, gcc-bugs, tobi
Priority: P2 Keywords: ice-on-valid-code
Version: 4.0.0   
Target Milestone: ---   
Host: i686-pc-linux-gnu Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2004-11-21 18:47:02
Bug Depends on:    
Bug Blocks: 17423, 19292    

Description Jerry DeLisle 2004-11-21 18:36:49 UTC
[jerry@quantum debug]$ f95 554RED.f
554RED.f: In function ‘MAIN__’:
554RED.f:8: internal compiler error: in gfc_add_modify_expr, at fortran/trans.c:154

The code is as follows:

      PROGRAM FM020

      LOGICAL LFTN01, LDTN01                                            00250020

C..... TEST 554                                                         00340020
      LFTN01(LDTN01) = .TRUE.                                           00350020

      IVTNUM = 554                                                      01630020
C                                                                       01640020
C      ****  TEST 554  ****                                             01650020
C     TEST 554  -  TEST OF THE STATEMENT FUNCTION OF TYPE LOGICAL       01660020
C     SET TO THE LOGICAL CONSTANT .TRUE. REGARDLESS OF THE              01670020
C     ARGUEMENT SUPPLIED TO THE DUMMY ARGUEMENT.                        01680020
C     A LOGICAL    IF STATEMENT IS USED IN CONJUNCTION WITH THE LOGICAL 01690020
C     STATEMENT FUNCTION.  THE TRUE PATH IS TESTED.                     01700020
C                                                                       01710020
      IF ( LFTN01(.FALSE.) )  IVON01 = 1                                01760020
      END                                                               04810020

The offending statement is the IF just before the END.
Comment 1 Andrew Pinski 2004-11-21 18:47:02 UTC
Confirmed.
Comment 2 Steve Kargl 2005-01-02 19:10:49 UTC
Here a further reduction of the problem.

This compiles fine

     logical a, b
     a(b) = .true.
     b = .false.
     if (a(b)) b = .true.
     end

The parse tree is

      ASSIGN b .false.
      IF a[[((b))]]
        ASSIGN b .true.
      ENDIF


This causes the ICE.

      logical a, b
      a(b) = .true.
      if (a(.false.)) b = .true.
      end

with the following parse tree

      IF a[[((.false.))]]
        ASSIGN b .true.
      ENDIF

The problem is in gfc_conv_statement_function(), which apparently
can't deal with an actual named constant parameter for its argument.

Unfortunately, I still don't know how to fix this.
Comment 3 Tobias Schlüter 2005-03-13 17:32:47 UTC
This works for me.  Can anybody else still confirm this?  Otherwise I'll add
this to the testsuite.
Comment 4 Andrew Pinski 2005-03-13 17:35:22 UTC
This works for me also.
Comment 5 Jerry DeLisle 2005-03-13 19:04:19 UTC
I also confirm that the ICE no longer occurs.  Running the original FM020.f test
program passes all tests.
Comment 6 GCC Commits 2005-03-13 19:28:27 UTC
Subject: Bug 18600

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tobi@gcc.gnu.org	2005-03-13 19:28:19

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: stfunc_1.f90 

Log message:
	PR fortran/18600
	* gfortran.dg/stfunc_1.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5156&r2=1.5157
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/stfunc_1.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 7 Tobias Schlüter 2005-03-13 19:28:45 UTC
Works now.