dump (dumper::TREE) && dump ("CDTOR %N is %scloned",
decl, cloned_p ? "" : "not ");
if (cloned_p)
- build_cdtor_clones (decl, flags & 2, flags & 4,
- /* Update the member vec, if there is
- one (we're in a different cluster
- to the class defn). */
- CLASSTYPE_MEMBER_VEC (DECL_CONTEXT (decl)));
+ {
+ /* Update the member vec, if there is one (we're in a different
+ cluster to the class defn) and this isn't a primary template
+ specialization (as in tsubst_function_decl). */
+ bool up = (CLASSTYPE_MEMBER_VEC (DECL_CONTEXT (decl))
+ && !primary_template_specialization_p (decl));
+ build_cdtor_clones (decl, flags & 2, flags & 4, up);
+ }
}
}
--- /dev/null
+// Test that a random instantiation of a constructor template doesn't end up in
+// the overload set for other arguments.
+
+// { dg-do compile { target c++20 } }
+// { dg-additional-options "-fmodules" }
+
+export module M;
+
+export {
+ inline int i;
+
+ template <class T>
+ struct A {
+ A(const T* p, unsigned long len) { ++i; }
+ template <class B, class E>
+ requires (!__is_convertible(E,unsigned long))
+ A(B,E) { ++i; }
+ };
+
+ inline void f()
+ {
+ const char *const p = nullptr;
+ A<char> a (p, p); // instantiate A<const char *, const char *>
+ }
+}