https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107467
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Here is the unincluded version of the source: #include <utility> template <typename C> bool __attribute__((noinline)) compare_pairs(const std::pair<int, C> &lhs, const std::pair<int, C> &rhs) { return lhs.first == rhs.first && lhs.second == rhs.second; } template <typename B> struct Combined { std::pair<int, B *> __attribute__((noinline)) get_const() { return std::make_pair(123, nullptr); } bool __attribute__((noinline)) clashy() { return compare_pairs(get_const(), get_const()); } }; class SomeClass {}; class OtherClass {}; void some_func() { Combined<SomeClass> myvar; __builtin_printf("%i\n", myvar.clashy()); } void other_func() { Combined<OtherClass> myvar; __builtin_printf("%i\n", myvar.clashy()); }