[Bug c++/63540] Erroneous "'Derived' declares a move constructor or move assignment operator" in error.
danregister at poczta dot fm
gcc-bugzilla@gcc.gnu.org
Mon Apr 27 15:57:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63540
Daniel Adamski <danregister at poczta dot fm> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |danregister at poczta dot fm
--- Comment #2 from Daniel Adamski <danregister at poczta dot fm> ---
I have another variant of that issue:
----------------------------------------------------------------
struct Base
{
Base() {}
Base(const Base &) {}
Base & operator=(Base &&) { return *this; }
};
struct D1 : Base
{
using Base::operator=;
D1 & operator=(const D1&) { return *this; }
};
int main()
{
D1 x;
D1 y = x;
(void) y;
}
----------------------------------------------------------------
The error:
----------------------------------------------------------------
test.cpp: In function ‘int main()’:
test.cpp:19:12: error: use of deleted function ‘D1::D1(const D1&)’
D1 y = x;
^
test.cpp:10:8: note: ‘D1::D1(const D1&)’ is implicitly declared as deleted
because ‘D1’ declares a move constructor or move assignment operator
struct D1 : Base
----------------------------------------------------------------
It's enough to remove one of the lines (any one) from D1 for the error to go
away.
Yet another variant:
----------------------------------------------------------------
struct Base
{
Base() {}
Base(const Base &) {}
Base & operator=(Base &&) { return *this; }
};
struct D1 : Base
{
using Base::operator=;
};
struct D2 : D1
{
D2 & operator=(const D2 &) { return *this; }
};
int main()
{
D1 x;
D1 y = x;
(void) y;
}
----------------------------------------------------------------
The error is the same. The "operator=()" in "D2" doesn't have to be D2's
assignment operator. It may some other "operator()", e.g., "operator(int)" or
it may be "using D1::operator=;" or "using Base::operator=;"
More information about the Gcc-bugs
mailing list