[PATCH] D104500: [clang] Apply P1825 as Defect Report from C++11 up to C++20.

Matheus Izvekov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 26 17:59:58 PDT 2021


mizvekov added inline comments.


================
Comment at: clang/lib/Sema/SemaStmt.cpp:3478-3481
+        // Check that overload resolution selected a conversion operator
+        // taking an rvalue reference.
+        if (cast<CXXMethodDecl>(FD)->getRefQualifier() != RQ_RValue)
+          break;
----------------
rsmith wrote:
> Is the removal of this check for an rvalue ref qualifier a bugfix? If so, please add a test. I suppose it would look something like this:
> ```
> struct B;
> struct A { A(B&) = delete; };
> struct B { operator A(); };
> A f() { B b; return b; }
> ```
> ... which would be ambiguous if we don't implicitly convert to xvalue, but if we do, it selects a conversion function that is not rvalue-ref-qualified.
Yeah you are right. I was reading that section of the standard again in bed to try to get some sleep, and it suddenly clicked me that we were just supposed to be doing that first overload resolution with the expression as an xvalue and that is it. There was no reason to be anything else in there.
I just could not resist the urge to get up and fix it thought :)
I'll leave the test case for tomorrow though!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104500/new/

https://reviews.llvm.org/D104500



More information about the cfe-commits mailing list