https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87906
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> --- Better test-cases that do not violate ODR: $ 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 a { public: ~a(); }; class b { public: ~b(); a c; }; class c { b e; }; class RuntimeException : b {}; } // 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(); }