https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115285
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- Or r12-6272-ge3ef832a9e8d6a I think the testcase is invalid. The unordered_set<TrimmedStr> uses std::equal_to<TrimmedStr> to decide if a key already exists in the container, and that just uses operator== which is not defined for TrimmedStr, so it uses the equality comparison for std::string. When that is used to compare TrimmedStr("foo") == "foo "s it's equivalent to "foo"s == "foo "s which is obviously false.