Platform: Fedora release 7 (Moonshine) Linux idle.lbl.gov 2.6.22.9-91.fc7 #1 SMP Thu Sep 27 20:47:39 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux % g++ -v Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: /net/rosie/scratch2/rwgk/gcc_trunk/configure --prefix=/net/cci-filer1/vol1/tmp/rwgk/gcc_trunk_130232_x86_64_fc7 --enable-languages=c,c++,fortran --with-mpfr=/usr Thread model: posix gcc version 4.3.0 20071116 (experimental) (GCC) I'll attach a stand-alone reproducer. It works with -O0 but not -O1 or higher: % gcc -c -fno-strict-aliasing -O1 -Wall ice_ssa.c ice_ssa.c: In function 's_init': ice_ssa.c:281: internal compiler error: in get_addr_dereference_operands, at tree-ssa-operands.c:1688 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. The reproducer is derived from: Python-2.5.1/Modules/_struct.c It is still quite big (297 lines) but has no external dependencies. I've spend a significant amount of time stripping it down starting from ca. 6000 lines of pre-processed code. I hope you can do the rest much faster than I could. Ralf
Created attachment 14568 [details] reproducer
Works for me, this is a dup of PR34113. *** This bug has been marked as a duplicate of 34113 ***
(In reply to comment #2) > Works for me, this is a dup of PR34113. > > *** This bug has been marked as a duplicate of 34113 *** > This is not the case. My original bug report was based on svn revision 130232, which includes the fix for PR34113 (fixed with svn revision 130223). I tried again today from scratch with svn revision 130261 (this time under Fedora 5 because the other machine crashed): % gcc -fPIC -c -O3 ice_ssa_34127.c ice_ssa_34127.c: In function 'prepare_s': ice_ssa_34127.c:297: internal compiler error: in get_addr_dereference_operands, at tree-ssa-operands.c:1688 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions.
Whoops, sorry. Reduced testcase: static void whichtable(char **pfmt) { --*pfmt; } void prepare_s(const char *fmt) { whichtable((char **)&fmt); } ./cc1 -quiet -O t2.i t2.i: In function 'prepare_s': t2.i:7: internal compiler error: in get_addr_dereference_operands, at tree-ssa-operands.c:1688 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions.
Hm, this is an unlucky case because of the way fold_stmt works. What we have is (even more simplified): void prepare_s(const char *fmt) { char ** f = (char **)&fmt; *f = 0; } where it is not hard to see that for the store we can substitute fmt = 0; as a char * rhs can be trivially converted to a const char * lhs. Now what happens is that forwprop decides for this reason that a propagation of (char **)&fmt is worthwhile and asks fold_stmt_in_place to fold *(char **)&fmt = 0; now the path goes through maybe_fold_stmt_indirect which only strips same-type conversions (STRIP_TYPE_NOPS) and so fails to dispatch to maybe_fold_offset_to_reference. Now, if we strip the conversion in forwprop already then in turn maybe_fold_offset_to_reference fails to do the conversion because it (even while it would strip all conversions) asks if the conversion from const char * to char * is useless (which it is not) and refuses to do the trivial folding.
Subject: Bug 34127 Author: rguenth Date: Sun Nov 18 15:49:57 2007 New Revision: 130269 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130269 Log: 2007-11-18 Richard Guenther <rguenther@suse.de> PR tree-optimization/34127 * tree-ssa-forwprop.c (tree_ssa_forward_propagate_single_use_vars): Make code match up the comments, require compatibility of the pointed-to types. * gcc.c-torture/compile/pr34127.c: New testcase. Added: trunk/gcc/testsuite/gcc.c-torture/compile/pr34127.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-forwprop.c
Fixed.
*** Bug 34122 has been marked as a duplicate of this bug. ***