From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19972 invoked by alias); 22 Dec 2013 17:30:24 -0000 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 Received: (qmail 19935 invoked by uid 48); 22 Dec 2013 17:30:18 -0000 From: "Konstantin.Sadov at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/59579] New: Defaulted copy constructor of template class is instantiated even when not called (probably bug 57153) Date: Sun, 22 Dec 2013 17:30:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.7.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: Konstantin.Sadov at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-12/txt/msg02028.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59579 Bug ID: 59579 Summary: Defaulted copy constructor of template class is instantiated even when not called (probably bug 57153) Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: Konstantin.Sadov at gmail dot com The following code struct A{A()=default;A(A&)=default;}; templatestruct C:B{C()=default; #if 1 C(const C&)=default;//Fails #else C(const C&c):B(c){};//Works #endif }; C d; int main(){} produces the following error $g++ -std=c++11 main.cpp main.cpp: In instantiation of 'struct C': main.cpp:9:6: required from here main.cpp:4:1: error: 'C::C(const C&) [with B = A]' declared to take const reference, but implicit declaration would take non-const C(const C&)=default;//Fails ^ Looks like defaulted function is implicitly instantiated even if it's not used (it's not so for user-defined functions). GCC 4.4 worked well with this case.