Bug 12632 - [g77 3.3/3.4 Regression] [g77 only] -fbounds-check ICE
Summary: [g77 3.3/3.4 Regression] [g77 only] -fbounds-check ICE
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 3.3.1
: P3 critical
Target Milestone: 3.3.3
Assignee: Roger Sayle
URL:
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2003-10-16 05:22 UTC by susukita@atlas.riken.go.jp
Modified: 2004-01-17 04:22 UTC (History)
2 users (show)

See Also:
Host: i586-pc-linux-gnu
Target: i586-pc-linux-gnu
Build: i586-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2003-10-18 16:56:21


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description susukita@atlas.riken.go.jp 2003-10-16 05:22:20 UTC
The following test.f makes an ICE.
      INTEGER I(1)
      I(2) = 0
      END

Environment:
System: Linux 2.2.19
Architecture: i586

host: i586-pc-linux-gnu
build: i586-pc-linux-gnu
target: i586-pc-linux-gnu
configured with: ./configure --enable-languages=f77

How-To-Repeat:
g77 -fbounds-check test.f
Comment 1 Andrew Pinski 2003-10-18 16:56:21 UTC
I can confirm this on the mainline (20031017).  It does not happen with 3.2.3 so it is a 
regression but I do not know if anyone will fix this one though as this is fixed in the tree-
ssa with f95 which is the future.
Comment 2 Andrew Pinski 2003-12-20 23:03:44 UTC
Caused by this patch: <http://gcc.gnu.org/ml/gcc-patches/2002-10/msg00873.html>.
Roger could you look into this.
Comment 3 Andrew Pinski 2003-12-21 09:04:21 UTC
I have a fix but it looks wrong after reading why this was changed in the first place.
Comment 4 Andrew Pinski 2003-12-21 09:05:44 UTC
In fact the fix does not help for optimizations either so it ICE at -O.
Comment 5 roger 2003-12-26 14:23:40 UTC
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2003-12/msg01878.html>
Comment 6 CVS Commits 2003-12-29 16:16:45 UTC
Subject: Bug 12632

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	sayle@gcc.gnu.org	2003-12-29 16:16:39

Modified files:
	gcc            : ChangeLog fold-const.c 
	gcc/f          : ChangeLog com.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g77.dg: 12632.f 

Log message:
	PR fortran/12632
	* fold-const.c (fold) <COND_EXPR>: Don't fold a constant condition,
	if the type of the selected branch doesn't match its' parent.
	
	* com.c (ffecom_subscript_check_): Take as an extra argument the
	(possibly NULL) decl of the array.  Don't create unnecessary tree
	nodes if the array index is known to be safe at compile-time.
	If the array index is unsafe, force the array decl into memory to
	avoid RTL expansion problems.
	(ffecom_array_ref_): Update calls to ffecom_subscript_check_.
	(ffecom_char_args_x_): Likewise.
	
	* g77.dg/12632.f: New test case.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.2108&r2=2.2109
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.318&r2=1.319
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/f/ChangeLog.diff?cvsroot=gcc&r1=1.617&r2=1.618
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/f/com.c.diff?cvsroot=gcc&r1=1.220&r2=1.221
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3318&r2=1.3319
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g77.dg/12632.f.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 7 Andrew Pinski 2003-12-29 16:59:47 UTC
Fixed for 3.4.
Comment 8 CVS Commits 2004-01-01 04:45:04 UTC
Subject: Bug 12632

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	sayle@gcc.gnu.org	2004-01-01 04:44:59

Modified files:
	gcc            : ChangeLog tree.c tree.h fold-const.c 
	gcc/f          : ChangeLog com.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g77.dg: 12632.f 

Log message:
	PR fortran/12632
	* tree.c (integer_nonzerop): New predicate for nonzero integers.
	* tree.h (integer_nonzerop): Add function prototype.
	* fold-const.c (fold) <COND_EXPR>: Don't fold a constant condition,
	if we'd replace a COND_EXPR of non-void type by one of its operands
	of void type.
	
	* com.c (ffecom_subscript_check_): Take as an extra argument the
	(possibly NULL) decl of the array.  Don't create unnecessary tree
	nodes if the array index is known to be safe at compile-time.
	If the array index is unsafe, force the array decl into memory to
	avoid RTL expansion problems.
	(ffecom_array_ref_): Update calls to ffecom_subscript_check_.
	(ffecom_char_args_x_): Likewise.
	
	* g77.dg/12632.f: New test case.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.864&r2=1.16114.2.865
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.282.2.3&r2=1.282.2.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.367.2.7&r2=1.367.2.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.227.2.4&r2=1.227.2.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/f/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.503.2.34&r2=1.503.2.35
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/f/com.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.182.4.5&r2=1.182.4.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.348&r2=1.2261.2.349
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g77.dg/12632.f.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.4.1

Comment 9 Andrew Pinski 2004-01-01 05:10:22 UTC
Fixed also for 3.3.3.