https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113529
Bug ID: 113529
Summary: Incorrect result of requires-expression in case of
function call ambiguity
Product: gcc
Version: 13.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
In this program
#include <compare>
struct A {
auto operator <=>(const A&) const = default;
bool operator <(const A&) const = default;
};
struct B {
auto operator <=>(const B&) const = default;
};
struct C : A, B {};
template<typename T>
concept Cmp = requires(T u, T v) { u < v; };
//auto cmp = C{} < C{}; //this correctly fails due to ambiguity
static_assert( !Cmp<C> ); //but this evaluates wrongly in GCC
C{} < C{} is correctly rejected as ambiguous, but for some reason `requires` in
GCC returns that the objects can be compared. This program is accepted by Clang
truck (to be v18). Online demo: https://godbolt.org/z/76zoYMd6h
Explanation of ambiguity: https://stackoverflow.com/a/69245639/7325599