Created attachment 31040 [details] the output g++ The error goes away if "edges" is defined in "main.cpp" instead of in "extra.cpp", so I have attached "main.ii" and "extra.ii". "output" is the output of "g++ -v -save-temps -Wall -Wextra -fno-strict-aliasing -fwrapv -fno-aggressive-loop-optimizations -O3 main.cpp extra.cpp". I have tried to simplify "main.cpp" further, but many changes make the error go away.
Created attachment 31041 [details] preprocessed source
Created attachment 31042 [details] preprocessed source
I can reproduce in 4_8-branch but I can't in mainline. I doubt however this is a C++ front-end issue, eg it goes away with -O2. Adding Honza in CC, because the backtrace includes tree-inline.c: main.cpp: In function ‘int main(int, char**)’: main.cpp:43:9: internal compiler error: Segmentation fault delete_and_nullify_entries(number_to_copy); ^ 0x90401f crash_signal /scratch/Gcc/svn-dirs/gcc-4_8-branch/gcc/toplev.c:332 0x940ac0 expand_call_inline /scratch/Gcc/svn-dirs/gcc-4_8-branch/gcc/tree-inline.c:3813 0x940ac0 gimple_expand_calls_inline /scratch/Gcc/svn-dirs/gcc-4_8-branch/gcc/tree-inline.c:4161 0x940ac0 optimize_inline_calls(tree_node*) /scratch/Gcc/svn-dirs/gcc-4_8-branch/gcc/tree-inline.c:4315 0xcca7c8 inline_transform(cgraph_node*) /scratch/Gcc/svn-dirs/gcc-4_8-branch/gcc/ipa-inline-transform.c:415 0x86f0b9 execute_one_ipa_transform_pass /scratch/Gcc/svn-dirs/gcc-4_8-branch/gcc/passes.c:2175 0x86f0b9 execute_all_ipa_transforms() /scratch/Gcc/svn-dirs/gcc-4_8-branch/gcc/passes.c:2211 0x6ca0ba expand_function /scratch/Gcc/svn-dirs/gcc-4_8-branch/gcc/cgraphunit.c:1633 0x6cb562 expand_all_functions /scratch/Gcc/svn-dirs/gcc-4_8-branch/gcc/cgraphunit.c:1744 0x6cb562 compile() /scratch/Gcc/svn-dirs/gcc-4_8-branch/gcc/cgraphunit.c:2042 0x6cbac4 finalize_compilation_unit() /scratch/Gcc/svn-dirs/gcc-4_8-branch/gcc/cgraphunit.c:2119 0x59a4a8 cp_write_global_declarations() /scratch/Gcc/svn-dirs/gcc-4_8-branch/gcc/cp/decl2.c:4333 Please submit a full bug report,
ICEs with -O2 -fipa-cp-clone on the 4.8 branch: main.cpp:16:1: error: inlined_to pointer set for noninline callers main.cpp:16:1: error: multiple inline callers _ZN5ArrayI11edge_structE26delete_and_nullify_entriesEii/25 (void Array<Type>::delete_and_nullify_entries(int, int) [with Type = edge_struct]) @0x7eff9b99acb8 Type: function Visibility: public weak comdat comdat_group:_ZN5ArrayI11edge_structE26delete_and_nullify_entriesEii one_only virtual References: Referring: Function void Array<Type>::delete_and_nullify_entries(int, int) [with Type = edge_struct]/25 is inline copy in int main(int, char**)/3 Availability: local Function flags: analyzed body local finalized Called by: _ZN5ArrayI11edge_structE4growEib.constprop.2/21 (1.19 per call) _ZN5ArrayI11edge_structE5clearEb/10 (0.30 per call) (inlined) (indirect_inlining) (can throw external) Calls: main.cpp:16:1: internal compiler error: verify_cgraph_node failed a regression from 4.7.x. Eventually the bug was fixed on trunk but the fix not backported. Martin?
Well, IPA-CP devirtualization is required to trigger the bug but it is a clone materialization problem. The following line (invoked as a consequence of fold_stmt devirtualization) in cgraph_update_edges_for_call_stmt_node causes the bug: ne = cgraph_create_edge (node, cgraph_get_create_node (new_call), new_stmt, count, frequency); cgraph_get_create_node returns an inlined clone and it gets an extra caller edge. Verifier then complains there is an un-inlined edge to an inlined node but the problem really is that there are two edges. Either we need to make sure that we keep an un-inlined node for devirtualization which cgraph_get_create_node can pick up until we are done with materializations, ore need to backport and use cgraph_get_create_real_symbol_node from http://gcc.gnu.org/ml/gcc-patches/2013-03/msg00621.html
OK, I did the bisecting and the bug has been properly fixed on trunk by http://gcc.gnu.org/ml/gcc-patches/2013-05/msg00366.html I did not want to backport it unless there was a bug but since there is one now, I am going to backport both r196750 and r198743 to the 4.8 branch after testing (Honza has pre-approved it in person).
Author: jamborm Date: Tue Oct 29 14:32:13 2013 New Revision: 204163 URL: http://gcc.gnu.org/viewcvs?rev=204163&root=gcc&view=rev Log: 2013-10-29 Martin Jambor <mjambor@suse.cz> PR middle-end/58789 Backport from mainline 2013-05-09 Martin Jambor <mjambor@suse.cz> PR lto/57084 * gimple-fold.c (canonicalize_constructor_val): Call cgraph_get_create_real_symbol_node instead of cgraph_get_create_node. Backport from mainline 2013-03-16 Jan Hubicka <jh@suse.cz> * cgraph.h (cgraph_get_create_real_symbol_node): Declare. * cgraph.c (cgraph_get_create_real_symbol_node): New function. * cgrpahbuild.c: Use cgraph_get_create_real_symbol_node instead of cgraph_get_create_node. * ipa-prop.c (ipa_make_edge_direct_to_target): Likewise. Modified: branches/gcc-4_8-branch/gcc/ChangeLog branches/gcc-4_8-branch/gcc/cgraph.c branches/gcc-4_8-branch/gcc/cgraph.h branches/gcc-4_8-branch/gcc/cgraphbuild.c branches/gcc-4_8-branch/gcc/gimple-fold.c branches/gcc-4_8-branch/gcc/ipa-prop.c
Fixed with http://gcc.gnu.org/ml/gcc-patches/2013-10/msg02413.html