Here the used base<int>::operator= gets into the list of foo's bindings for operator=, but it shouldn't make the copy ctor deleted.
Tested x86_64-pc-linux-gnu, applying to trunk. * class.c (classtype_has_move_assign_or_move_ctor_p): Don't consider op= brought in by a using-declaration. --- gcc/cp/class.c | 4 ++- gcc/testsuite/g++.dg/cpp0x/implicit16.C | 37 +++++++++++++++++++++++++ gcc/cp/ChangeLog | 4 +++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/implicit16.C diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 0d4d35bd690..a70a852424e 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5220,7 +5220,9 @@ classtype_has_move_assign_or_move_ctor_p (tree t, bool user_p) for (ovl_iterator iter (get_class_binding_direct (t, assign_op_identifier)); iter; ++iter) - if ((!user_p || !DECL_ARTIFICIAL (*iter)) && move_fn_p (*iter)) + if ((!user_p || !DECL_ARTIFICIAL (*iter)) + && DECL_CONTEXT (*iter) == t + && move_fn_p (*iter)) return true; return false; diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit16.C b/gcc/testsuite/g++.dg/cpp0x/implicit16.C new file mode 100644 index 00000000000..229f2b4cd81 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/implicit16.C @@ -0,0 +1,37 @@ +// PR c++/89381 +// { dg-do compile { target c++11 } } + +template<typename T> +struct base +{ + base() { } + base(const base&) { } + base(base&&) { } + base& operator=(const base&) { return *this; } + base& operator=(base&&) { return *this; } +}; + +struct foo : base<int> +{ + using base<int>::base; + using base<int>::operator=; +}; + +//using workaround = decltype(foo{*static_cast<foo const*>(0)}); + +struct bar +{ + bar& operator=(foo ve) + { + value = ve; + return *this; + } + + foo value; +}; + +int main() +{ + foo a; + foo b{a}; +} diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a076fa9a255..848859e955e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2019-03-06 Jason Merrill <ja...@redhat.com> + PR c++/89381 - implicit copy and using-declaration. + * class.c (classtype_has_move_assign_or_move_ctor_p): Don't consider + op= brought in by a using-declaration. + PR c++/89576 - if constexpr of lambda capture. * semantics.c (maybe_convert_cond): Do convert a non-dependent condition in a template. base-commit: 02daf5d2ca0cd851d93e4d7299a95013cb405497 -- 2.20.1