[llvm-bugs] [Bug 42363] New: Diagnostics for "no matching constructor for initialization of ''" could be better

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jun 23 03:00:22 PDT 2019


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

            Bug ID: 42363
           Summary: Diagnostics for "no matching constructor for
                    initialization of ''" could be better
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lebedev.ri at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

https://godbolt.org/z/xxfpk7

struct A {};
struct B {
    explicit B(const A&, int a) {}
};
struct C {
    C(const B&) {}
};

void test(const A& a) {
    C c(a);
}

It rightfully complains that there is no way to convert A to C,
but never mentions the `explicit B(const A&, int a)`, and that it can't be
used because the value for the second argument is not present.


https://godbolt.org/z/EkOmZq
struct A {};
struct B {
    explicit B(const A&, int a = 0) {}
};
struct C {
    C(const B&) {}
};

void test(const A& a) {
    C c(a);
}

Same story, but even more surprising. It took me a moment to realize that
even if there is a default argument in `B`'s constructor,
it still wants it to be passed.

-- 
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/20190623/ad410d66/attachment.html>


More information about the llvm-bugs mailing list