[Bug c++/89381] New: Implicit copy constructor cannot be generated after unrelated class definition
nok.raven at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Feb 18 01:04:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89381
Bug ID: 89381
Summary: Implicit copy constructor cannot be generated after
unrelated class definition
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Keywords: diagnostic, needs-reduction, rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nok.raven at gmail dot com
Target Milestone: ---
For some reason `bar` makes `foo` not copy-constructible. It compiles if
you remove `bar`, or force compiler to generate copy-constructor before
`bar` definition.
#include <variant>
struct foo : std::variant<long, int>
{
using std::variant<long, int>::variant;
using std::variant<long, int>::operator=;
};
//using workaround = decltype(foo{*static_cast<foo const*>(0)});
struct bar
{
bar& operator=(foo ve)
{
value = std::move(ve);
return *this;
}
foo value;
};
int main()
{
foo a;
foo b{a};
}
prog.cc: In function 'int main()':
prog.cc:26:12: error: use of deleted function 'constexpr foo::foo(const foo&)'
26 | foo b{a};
| ^
prog.cc:3:8: note: 'constexpr foo::foo(const foo&)' is implicitly declared as
deleted because 'foo' declares a move constructor or move assignment operator
3 | struct foo : std::variant<long, int>
| ^~~
1
https://godbolt.org/z/DylgFW
More information about the Gcc-bugs
mailing list