https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65233
Bug ID: 65233 Summary: [5 Regression] ICE (segfault) on arm-linux-gnueabihf Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: doko at gcc dot gnu.org seen when building ardour on armhf, r220999 $ g++ -c -O3 audio_track.ii audio_track.ii: In function 'void export_stuff()': audio_track.ii:71:6: internal compiler error: Segmentation fault void export_stuff() { ^ Please submit a full bug report, with preprocessed source if appropriate. (gdb) bt #0 0x005ebd8e in integer_zerop(tree_node const*) () #1 0x003a1a2e in walk_ssa_copies(tree_node*, hash_set<tree_node*, default_hashset_traits>**) () #2 0x003a27a0 in ipa_polymorphic_call_context::ipa_polymorphic_call_context(tree_node*, tree_node*, gimple_statement_base*, tree_node**) () #3 0x0034f028 in fold_stmt_1(gimple_stmt_iterator*, bool, tree_node* (*)(tree_node*)) () #4 0x004c9070 in replace_uses_by(tree_node*, tree_node*) () #5 0x004c9554 in gimple_merge_blocks(basic_block_def*, basic_block_def*) () #6 0x0028242c in merge_blocks(basic_block_def*, basic_block_def*) () #7 0x004ce264 in cleanup_tree_cfg_bb(basic_block_def*) () #8 0x004ce6d8 in cleanup_tree_cfg() () #9 0x00432232 in execute_function_todo(function*, void*) () #10 0x004326b8 in execute_todo(unsigned int) () #11 0x00433f88 in execute_one_pass(opt_pass*) () #12 0x00434220 in execute_pass_list_1(opt_pass*) [clone .constprop.59] () #13 0x0043422a in execute_pass_list_1(opt_pass*) [clone .constprop.59] () #14 0x00434258 in execute_pass_list(function*, opt_pass*) () #15 0x00298a2a in cgraph_node::expand() () #16 0x0029a4b0 in symbol_table::compile() [clone .part.42] () #17 0x0029a6ec in symbol_table::finalize_compilation_unit() () #18 0x001a3210 in cp_write_global_declarations() () #19 0x004a916a in compile_file() () #20 0x00156ec2 in toplev::main(int, char**) () #21 0x00157914 in main () $ cat audio_track.ii template <class> class A; class B; struct C { A<B> &operator*(); }; int a; class D { public: virtual void m_fn1() {} void m_fn2() { m_fn1(); } }; class shared_count { D *pi_; public: shared_count() : pi_() {} ~shared_count() { if (pi_) pi_->m_fn2(); } shared_count(shared_count const &p1) : pi_(p1.pi_) { if (pi_) __sync_fetch_and_add(&a, 1); } void m_fn3(shared_count &p1) { D *b = p1.pi_; p1.pi_ = pi_; pi_ = b; } }; class G; struct F { typedef G *type; }; template <class T> class A { typedef A this_type; public: typedef T element_type; A() {} template <class Y> A(A<Y> &p1, element_type *p2) : px(p2), pn(p1.pn) {} A &operator=(A p1) { this_type(p1).m_fn5(*this); return *this; } element_type *m_fn4(); typedef element_type *this_type::*unspecified_bool_type; operator unspecified_bool_type() { return px ? 0 : &this_type::px; } void m_fn5(A &p1) { p1.px = px; pn.m_fn3(p1.pn); } element_type *px; shared_count pn; }; template <class, class U> A<G> dynamic_pointer_cast(A<U> &p1) { G *p = dynamic_cast<G *>(p1.m_fn4()); return p ? A<G>(p1, p) : A<G>(); } class B { public: void m_fn7(); virtual void m_fn6(); }; class G : public B {}; F::type c; void export_stuff() { C i; for (;;) { A<G> d; if (d = dynamic_pointer_cast<G>(*i)) c->m_fn7(); } }