[Bug libstdc++/115285] [12/13/14/15 Regression] std::unordered_set can have duplicate value

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu May 30 10:09:51 GMT 2024


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.


More information about the Gcc-bugs mailing list