This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/68190] New: iterator mix up with set::find and heterogenous lookup


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68190

            Bug ID: 68190
           Summary: iterator mix up with set::find and heterogenous lookup
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: howard.hinnant at gmail dot com
  Target Milestone: ---

This fails to compile because template <class Key> set::find is returning the
wrong iterator type (I think).

#include <set>

    struct Comparator
    {
        using is_transparent = std::true_type;

        bool
        operator() (int x, unsigned y) const
        {
            return x < y;
        }


        bool
        operator() (unsigned x, int y) const
        {
            return x < y;
        }


        bool
        operator() (int x, int y) const
        {
            return x < y;
        }

    };

int
main()
{
    std::set<int, Comparator> s;
    s.insert(1);
    auto iter = s.find(1u);
    iter = s.erase(iter);
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]