short string2int( const char * buf, unsigned len ) { return (len > 1) ? ( buf[len-1] - '0' ) + (short)10 * string2int(buf, len-1) : ( *buf - '0' ); } #include <assert.h> int main() { assert( string2int("13", 2) == 13); return 0; } At -O2 this program fails the assertion with 4.6 and 4.7 A 4.8 build with --enable-checking gets an ICE in verify_ssa $ ~/gcc/4.8/bin/gcc t.c -O2 t.c: In function 'string2int': t.c:12:1: error: definition in block 3 follows the use } ^ for SSA_NAME: _15 in statement: acc_tmp_17 = (short int) _15; t.c:12:1: internal compiler error: verify_ssa failed 0xa57004 verify_ssa(bool) ../../gcc-4.8/gcc/tree-ssa.c:1049 0x83ea9e execute_function_todo ../../gcc-4.8/gcc/passes.c:1967 0x83f56c execute_todo ../../gcc-4.8/gcc/passes.c:1999 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. Using -fno-optimize-sibling-calls makes the bug go away for all versions.
4.4.3 is OK, 4.5.2 fails the asertion
N.B. -O3 is needed to trigger the bug with 4.5.2
Confirmed.
bash-4.1$ x86_64-w64-mingw32-gcc -O2 t.c t.c: In function 'main': t.c:9:5: internal compiler error: Segmentation fault int main() ^ 0x71fa65 crash_signal ../../gcc-4_8-trunk/gcc/toplev.c:332 0x748617 ssa_default_def(function*, tree_node*) ../../gcc-4_8-trunk/gcc/tree-dfa.c:310 0x748688 get_or_create_ssa_default_def(function*, tree_node*) ../../gcc-4_8-trunk/gcc/tree-dfa.c:362 0x760f7c get_reaching_def ../../gcc-4_8-trunk/gcc/tree-into-ssa.c:1155 0x76364b maybe_replace_use ../../gcc-4_8-trunk/gcc/tree-into-ssa.c:1772 0x76364b rewrite_update_stmt ../../gcc-4_8-trunk/gcc/tree-into-ssa.c:1955 0x76364b rewrite_update_enter_block ../../gcc-4_8-trunk/gcc/tree-into-ssa.c:2124 0xab5380 walk_dominator_tree(dom_walk_data*, basic_block_def*) ../../gcc-4_8-trunk/gcc/domwalk.c:187 0x761183 rewrite_blocks ../../gcc-4_8-trunk/gcc/tree-into-ssa.c:2204 0x7669bc update_ssa(unsigned int) ../../gcc-4_8-trunk/gcc/tree-into-ssa.c:3283 0xb371a4 tree_unroll_loops_completely(bool, bool) ../../gcc-4_8-trunk/gcc/tree-ssa-loop-ivcanon.c:1175 0x7d4c92 tree_complete_unroll_inner ../../gcc-4_8-trunk/gcc/tree-ssa-loop.c:511 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. gcc version 4.8.0 20130305 (experimental) [gcc-4_8-trunk revision 196448]
I'd say this started with http://gcc.gnu.org/viewcvs?view=revision&revision=151935
Created attachment 29596 [details] gcc48-pr56539.patch Untested fix.
The patch fixes the problem for both 4.7 and 4.8, using the testcase above and the original C++ one it was reduced from.
Jakub, The patch also fixed this problem testcase on cross compiler (x86_64-w64-mingw32).
Author: jakub Date: Wed Mar 6 23:26:42 2013 New Revision: 196511 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196511 Log: PR tree-optimization/56539 * tree-tailcall.c (adjust_return_value_with_ops): Use GSI_SAME_STMT instead of GSI_CONTINUE_LINKING as last argument to force_gimple_operand_gsi. * gcc.c-torture/compile/pr56539.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/compile/pr56539.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-tailcall.c
Fixed on the trunk so far.
Author: jakub Date: Wed Apr 3 08:22:12 2013 New Revision: 197392 URL: http://gcc.gnu.org/viewcvs?rev=197392&root=gcc&view=rev Log: Backported from mainline 2013-03-06 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/56539 * tree-tailcall.c (adjust_return_value_with_ops): Use GSI_SAME_STMT instead of GSI_CONTINUE_LINKING as last argument to force_gimple_operand_gsi. Adjust function comment. * gcc.c-torture/compile/pr56539.c: New test. Added: branches/gcc-4_7-branch/gcc/testsuite/gcc.c-torture/compile/pr56539.c Modified: branches/gcc-4_7-branch/gcc/ChangeLog branches/gcc-4_7-branch/gcc/testsuite/ChangeLog branches/gcc-4_7-branch/gcc/tree-tailcall.c
Fixed for 4.7.3+ too.
Author: jakub Date: Wed Apr 3 18:05:09 2013 New Revision: 197451 URL: http://gcc.gnu.org/viewcvs?rev=197451&root=gcc&view=rev Log: Backported from mainline 2013-03-06 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/56539 * tree-tailcall.c (adjust_return_value_with_ops): Use GSI_SAME_STMT instead of GSI_CONTINUE_LINKING as last argument to force_gimple_operand_gsi. Adjust function comment. * gcc.c-torture/compile/pr56539.c: New test. Added: branches/gcc-4_6-branch/gcc/testsuite/gcc.c-torture/compile/pr56539.c Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/testsuite/ChangeLog branches/gcc-4_6-branch/gcc/tree-tailcall.c