[clang] [clang] Fix overload resolution ranking of inherited constructors (PR #132830)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 25 08:10:25 PDT 2025


================
@@ -169,6 +169,20 @@ B b;
 // since-cxx11-error at -1 {{call to implicitly-deleted default constructor of 'B'}}
 //   since-cxx11-note@#cwg2273-B {{default constructor of 'B' is implicitly deleted because base class 'A' has a deleted default constructor}}
 //   since-cxx11-note@#cwg2273-A {{'A' has been explicitly marked deleted here}}
+
+struct X {
+  X(float); // since-cxx11-note {{candidate inherited constructor}}
+  X(void*, int = 0) = delete;
+};
+
+struct Y : X {
+  using X::X; // since-cxx11-note {{constructor from base class 'X' inherited here}}
+  Y(double); // since-cxx11-note {{candidate constructor}}
+  Y(void* const, long = 1);
+};
+
+Y y = 1; // since-cxx11-error {{conversion from 'int' to 'Y' is ambiguous}}
+Y z = nullptr;
----------------
Endilll wrote:

The wording says "same type", but here you have two constructors, where their first parameter differs in cv-qualification. I suspect this case falls under the usual "exact match is better than qualification conversion" case, and doesn't need this tie-breaker, so this case is not related to CWG2273

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


More information about the cfe-commits mailing list