https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121327
Bug ID: 121327 Summary: Not-matching concept fails to compile with error "depends on itself" Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: b.stanimirov at abv dot bg Target Milestone: --- Consider the simple class: ``` template <typename T> class id { T m_id; public: constexpr id() : m_id() {} constexpr bool operator==(const id& other) const = default; template <std::equality_comparable_with<T> U> constexpr bool operator==(const U& other) const { return m_id == other; } }; ``` Instantiating an `id<T>` works as expected with id-id and id-U comparisons. But when inheriting from id as in: ``` struct user_id : public id<int> {}; ``` When comparing user_id==user_id the inherited operator== is no longer an exact match, so the compiler probes ==U, but instead of failing and trying the other overload, it produces a gigantic wall or errors, essentially saying that `equality_comparable_with` depends on itself. Live compiler explorer demo: https://godbolt.org/z/W9Kfzoh69 I'm not sure whether this is a compiler but or one in libstdc++, as I get the same error on clang with libstdc++, but not on msvc with msstl. I haven't tried libc++ yet.