[llvm-bugs] [Bug 44761] New: Overload resolution ignores "rewritten candidate" tiebreaker when functions are constrained

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Feb 3 08:28:58 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=44761

            Bug ID: 44761
           Summary: Overload resolution ignores "rewritten candidate"
                    tiebreaker when functions are constrained
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Casey at Carter.net
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Created attachment 23082
  --> https://bugs.llvm.org/attachment.cgi?id=23082&action=edit
Repro

Compiling this well-formed TU:

  #include <compare>

  template<int I>
  struct T {
      bool operator<(T const&) const;
      std::strong_ordering operator<=>(T const&) const;
  };

  bool f(T<2> const& x) {
      return x < x; // Fine
  }

  template<int I>
  struct S {
      bool operator<(S const&) const requires(I != 0);
      std::strong_ordering operator<=>(S const&) const requires(I != 1);
  };

  bool f(S<2> const& x) {
      return x < x; // Ambiguous??!?
  }

with "-std=c++2a" diagnoses:

  repro.cpp(20,14): error: use of overloaded operator '<' is ambiguous (with
operand types 'const S<2>' and 'const S<2>')
      return x < x; // Ambiguous??!?
             ~ ^ ~
  repro.cpp(15,10): note: candidate function
      bool operator<(S const&) const requires(I != 0);
           ^
  repro.cpp(16,26): note: candidate function
      std::strong_ordering operator<=>(S const&) const requires(I != 1);
                           ^
  repro.cpp(16,26): note: candidate function (with reversed parameter order)
  1 error generated.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200203/9de16401/attachment.html>


More information about the llvm-bugs mailing list