I forgot to set DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P when merging two
function declarations and as a sad consequence, we never tsubsted
the dependent explicit-specifier in tsubst_function_decl, leading to
disregarding the explicit-specifier altogether, and wrongly accepting
this test.
PR c++/95066
* decl.c (duplicate_decls): Set DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P.
* g++.dg/cpp2a/explicit16.C: New test.
+2020-05-13 Marek Polacek <polacek@redhat.com>
+
+ PR c++/95066
+ * decl.c (duplicate_decls): Set DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P.
+
2020-05-13 Nathan Sidwell <nathan@acm.org>
* pt.c (template_args_equal): Reorder category checking for
DECL_FINAL_P (newdecl) |= DECL_FINAL_P (olddecl);
DECL_OVERRIDE_P (newdecl) |= DECL_OVERRIDE_P (olddecl);
DECL_THIS_STATIC (newdecl) |= DECL_THIS_STATIC (olddecl);
+ DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P (newdecl)
+ |= DECL_HAS_DEPENDENT_EXPLICIT_SPEC_P (olddecl);
if (DECL_OVERLOADED_OPERATOR_P (olddecl))
DECL_OVERLOADED_OPERATOR_CODE_RAW (newdecl)
= DECL_OVERLOADED_OPERATOR_CODE_RAW (olddecl);
+2020-05-13 Marek Polacek <polacek@redhat.com>
+
+ PR c++/95066
+ * g++.dg/cpp2a/explicit16.C: New test.
+
2020-05-13 Jason Merrill <jason@redhat.com>
* lib/target-supports.exp (check_effective_target_c++20_only)
--- /dev/null
+// PR c++/95066 - explicit malfunction with dependent expression.
+// { dg-do compile { target c++2a } }
+
+template <typename T>
+struct Foo {
+ template <typename U>
+ explicit(static_cast<U>(true)) operator Foo<U>();
+};
+
+template <typename T>
+template <typename U>
+Foo<T>::operator Foo<U>() {
+ return {};
+}
+
+int
+main ()
+{
+ Foo<float> a;
+ Foo<int> b = a; // { dg-error "conversion" }
+}