[llvm-bugs] [Bug 47356] New: c++2a reports an error of overloaded operator while c++11/17 accepts

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Aug 30 06:39:24 PDT 2020


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

            Bug ID: 47356
           Summary: c++2a reports an error of overloaded operator while
                    c++11/17 accepts
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tangyixuan at mail.dlut.edu.cn
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

The following code is rejected by -std=c++2a, while ok with -std=c++11 or
-std=c++17.

$ cat s.cpp
template<typename T>
struct A {
  A() {}

  template<typename U>
    A(const A<U>&) {}

  bool operator==(const A&) const { return true; }
};

A<const int> a;
A<int> b;
auto c = (a == b);

$ clang -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
ab4627364aefcaac751e757b721b7d07b48a545a)
Target: x86_64-unknown-linux-gnu
Thread model: posix

$ clang++ -c -std=c++17 s.cpp
success.

$ clang++ -c -std=c++2a s.cpp
s.cpp:13:13: error: use of overloaded operator '==' is ambiguous (with operand
types 'A<const int>' and 'A<int>')
auto c = (a == b);
          ~ ^  ~
s.cpp:8:8: note: candidate function
  bool operator==(const A&) const { return true; }
       ^
s.cpp:8:8: 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/20200830/9f45807d/attachment.html>


More information about the llvm-bugs mailing list