https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87906
Bug ID: 87906 Summary: [9 Regression] ICE in tree check: expected block, have function_decl in block_ultimate_origin, at tree.c:12326 since r264734 Product: gcc Version: 9.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: marxin at gcc dot gnu.org CC: marxin at gcc dot gnu.org Target Milestone: --- Following 2 files cause an ICE: $ cat 1.ii namespace com { namespace sun { namespace star {} } // namespace sun } // namespace com namespace a = com::sun::star; namespace com { namespace sun { namespace star { namespace uno { class b { public: ~b(); }; class c { b e; }; class RuntimeException : c {}; } // namespace uno } // namespace star } // namespace sun } // namespace com template <typename> void d(int) { throw a::uno::RuntimeException(); } int f; void g() { d<a::uno::b>(f); } $ cat 2.ii namespace com { namespace sun { namespace star { namespace uno { class a { public: ~a(); }; class b { a c; }; class RuntimeException : b {}; } // namespace uno class C : uno::RuntimeException {}; } // namespace star } // namespace sun } // namespace com using com::sun::star::C; using com::sun::star::uno::RuntimeException; void d() { throw RuntimeException(); } void e() { C(); } $ g++ [12].ii -O -shared -fPIC -flto 1.ii:11:7: warning: type ‘struct b’ violates the C++ One Definition Rule [-Wodr] 11 | class b { | ^ 1.ii:11:7: note: a different type is defined in another translation unit 2.ii:10:5: note: the first difference of corresponding definitions is field ‘c’ 10 | a c; | ^ 1.ii:11:7: note: a type with different number of fields is defined in another translation unit 11 | class b { | ^ 1.ii:18:7: warning: type ‘struct RuntimeException’ violates the C++ One Definition Rule [-Wodr] 18 | class RuntimeException : c {}; | ^ 1.ii:18:7: note: a type with different bases is defined in another translation unit during GIMPLE pass: optimized 2.ii: In function ‘e’: 2.ii:21:6: internal compiler error: tree check: expected block, have function_decl in block_ultimate_origin, at tree.c:12326 21 | void e() { C(); } | ^ 0x7d56a6 tree_check_failed(tree_node const*, char const*, int, char const*, ...) /home/marxin/Programming/gcc/gcc/tree.c:9544 0x7dca31 tree_check(tree_node*, char const*, int, char const*, tree_code) /home/marxin/Programming/gcc/gcc/tree.h:3118 0x7dca31 block_ultimate_origin(tree_node const*) /home/marxin/Programming/gcc/gcc/tree.c:12324 0x184709b inlined_polymorphic_ctor_dtor_block_p(tree_node*, bool) /home/marxin/Programming/gcc/gcc/ipa-polymorphic-call.c:516 0x2a06f91 remove_unused_scope_block_p /home/marxin/Programming/gcc/gcc/tree-ssa-live.c:420 0x2a074a5 remove_unused_scope_block_p /home/marxin/Programming/gcc/gcc/tree-ssa-live.c:516 0x2a074a5 remove_unused_scope_block_p /home/marxin/Programming/gcc/gcc/tree-ssa-live.c:516 0x2a0f17e remove_unused_locals() /home/marxin/Programming/gcc/gcc/tree-ssa-live.c:896 0x1e65964 execute_function_todo /home/marxin/Programming/gcc/gcc/passes.c:1920 0x1e6709e execute_todo /home/marxin/Programming/gcc/gcc/passes.c:1996