struct S { long int l; void *m; }; int foo (struct S *x) { unsigned long a; a = x->l; if (a <= ((void *) 0)) x->m = 0; return 0; } ICEs at -O2 on both x86_64-linux and ppc-linux.
I'd say this is a frontend bug (in all of 4.1/4.2/4.3 at least), it shouldn't have created <eq_expr 0x2aaaadff85a0 type <boolean_type 0x2aaaae0018f0 _Bool public unsigned QI size <integer_cst 0x2aaaadff2660 constant invariant 8> unit size <integer_cst 0x2aaaadff2690 constant invariant 1> align 8 symtab 0 alias set -1 precision 1 min <integer_cst 0x2aaaadff2e40 0> max <integer_cst 0x2aaaadff2ea0 1>> arg 0 <ssa_name 0x2aaaae1bd700 type <integer_type 0x2aaaae0016e0 long unsigned int sizes-gimplified public unsigned DI size <integer_cst 0x2aaaadff2c00 constant invariant 64> unit size <integer_cst 0x2aaaadff2c30 constant invariant 8> align 64 symtab 0 alias set -1 precision 64 min <integer_cst 0x2aaaadff2d20 0> max <integer_cst 0x2aaaadff2cf0 18446744073709551615>> var <var_decl 0x2aaaae1a8b00 a> def_stmt <modify_expr 0x2aaaadff8550> version 3> arg 1 <integer_cst 0x2aaaae00c7e0 type <pointer_type 0x2aaaae011160> constant invariant 0> A.c:12> i.e. a comparison with integral type on one size and pointer on another one. In 4.2+ forwprop1 fixes this up to comparison against 0L, but in 4.1 it makes it through that up to vrp which asserts this is not the case.
Actually a bug in fold-const.
Subject: Bug 31632 Author: jakub Date: Fri Apr 20 12:40:47 2007 New Revision: 123988 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123988 Log: PR tree-optimization/31632 * fold-const.c (fold_binary): Use op0 and op1 instead of arg0 and arg1 for optimizations of comparison against min/max values. Fold arg0 to arg1's type for optimizations of comparison against min+1 and max-1 values. * gcc.c-torture/compile/20070419-1.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/compile/20070419-1.c Modified: trunk/gcc/ChangeLog trunk/gcc/fold-const.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 31632 Author: jakub Date: Fri Apr 20 12:46:06 2007 New Revision: 123990 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123990 Log: PR tree-optimization/31632 * fold-const.c (fold_binary): Use op0 and op1 instead of arg0 and arg1 for optimizations of comparison against min/max values. Fold arg0 to arg1's type for optimizations of comparison against min+1 and max-1 values. * gcc.c-torture/compile/20070419-1.c: New test. Added: branches/gcc-4_2-branch/gcc/testsuite/gcc.c-torture/compile/20070419-1.c Modified: branches/gcc-4_2-branch/gcc/ChangeLog branches/gcc-4_2-branch/gcc/fold-const.c branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
Subject: Bug 31632 Author: jakub Date: Fri Apr 20 12:49:37 2007 New Revision: 123992 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123992 Log: PR tree-optimization/31632 * fold-const.c (fold_binary): Use op0 and op1 instead of arg0 and arg1 for optimizations of comparison against min/max values. Fold arg0 to arg1's type for optimizations of comparison against min+1 and max-1 values. * gcc.c-torture/compile/20070419-1.c: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/gcc.c-torture/compile/20070419-1.c Modified: branches/gcc-4_1-branch/gcc/ChangeLog branches/gcc-4_1-branch/gcc/fold-const.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
Fixed.