https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93628
Bug ID: 93628
Summary: ranges::equal_to doesn't work for types convertible to
function pointers
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
#include <functional>
using F = void();
static_assert(std::equality_comparable_with<F*, F*>);
struct S {
constexpr operator F*() const { return nullptr; }
};
void operator!=(S const&, S const&) {}
// concept not satisfied because operator!= returns void
static_assert(!std::equality_comparable_with<S,S>);
// but S can be compared using == via conversion to F*
static_assert(S{} == S{});
// so these should be valid:
static_assert(std::ranges::equal_to{}(S{}, S{}));
static_assert(!std::ranges::not_equal_to{}(S{}, S{}));
The problem is that our implementation of BUILTIN-PTR-CMP(T, ==, U) checks for
conversion to void*, which isn't possible for function pointers. There's no
type that all function pointers are implicitly convertible.
This might not be implementable without a new built-in.