This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/50248] [C++0x] tries to use variadic constructor when it should use default constructor
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 31 Aug 2011 10:24:07 +0000
- Subject: [Bug c++/50248] [C++0x] tries to use variadic constructor when it should use default constructor
- Auto-submitted: auto-generated
- References: <bug-50248-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50248
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-08-31 10:24:07 UTC ---
Thanks for not posting an example of 30k lines :)
another workaround is to add these constructors:
MapSessionData(const MapSessionData&) = delete;
MapSessionData() = default;
The error does not come from failing to use the default constructor, it comes
from the implicit-definition of the MapSessionData copy constructor.
[class.copy]/8 says:
- earray has an implicitly-declared copy-constructor of the form earray(const
earray&),
- MapSessionData has an implicitly-declared copy constructor of the form
MapSessionData(MapSessionData&) because its base class has a copy-constructor
taking a non-const parameter.
The implicitly-declared MapSessionData(MapSessionData&) copy-ctor should only
be implicitly-defined if it is odr-used (p13) so I'm not sure why it is, but
that implicit definition attempts to initialize equip_index with a non-const
parameter, which selects the variadic template because the earray(const earray)
constructor is not viable.
(The workaround above prevents the implicit-declaration of the MapSessionData
copy-ctor, so it doesn't attempt to use the variadic template.)
Jason, is it correct that the copy ctor is implicitly-defined?