From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19031 invoked by alias); 31 Aug 2011 10:24:30 -0000 Received: (qmail 19022 invoked by uid 22791); 31 Aug 2011 10:24:29 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 31 Aug 2011 10:24:13 +0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/50248] [C++0x] tries to use variadic constructor when it should use default constructor Date: Wed, 31 Aug 2011 10:31:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg02521.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50248 --- Comment #1 from Jonathan Wakely 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?