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
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.
Caused by this patch: <http://gcc.gnu.org/ml/gcc-patches/2002-10/msg00873.html>. Roger could you look into this.
I have a fix but it looks wrong after reading why this was changed in the first place.
In fact the fix does not help for optimizations either so it ICE at -O.
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2003-12/msg01878.html>
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
Fixed for 3.4.
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
Fixed also for 3.3.3.