[clang] [libcxx] [SemaCXX] Implement CWG2137 (list-initialization from objects of the same type) (PR #77768)

Mital Ashok via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 24 11:32:14 PST 2024


MitalAshok wrote:

With the standard as is, `B(A)` should be a better match because of [[over.ics.list]p(7.1)](https://wg21.link/over.ics.list#7.1), it is an Exact Match, and `B(std::vector<A>)` is a user defined conversion.

With the current CWG2311 fix, the call to `B(A)` is an Exact Match because it's an `A` prvalue.

https://github.com/llvm/llvm-project/blob/7b11c08c664863fbcd7a3058179b0af3de5d28e4/clang/lib/Sema/SemaOverload.cpp#L1593

^ This line is the issue: `isCopyConstructor()` checks only for lvalue reference copy constructors, and the move constructor is selected (i.e., if you force a copy constructor to be called instead, it works: https://godbolt.org/z/rGEsPdMx8)

Removing `Constructor->isCopyConstructor() &&` fixes the issue (`B(A)` is chosen, and all existing tests still pass)

@cor3ntin I have some extra test cases I would want to add too. Should I make a new pull request? Or are we going to reopen this one and target llvm 19?


https://github.com/llvm/llvm-project/pull/77768


More information about the cfe-commits mailing list