From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8725 invoked by alias); 26 Jun 2013 14:43:03 -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 8694 invoked by uid 48); 26 Jun 2013 14:42:59 -0000 From: "bmerry at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/57728] New: Explicit template instantiation with defaulted method causes missing symbol Date: Wed, 26 Jun 2013 14:43: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.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bmerry 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 attachments.created 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-06/txt/msg01590.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57728 Bug ID: 57728 Summary: Explicit template instantiation with defaulted method causes missing symbol Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: bmerry at gmail dot com Created attachment 30378 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30378&action=edit Minimal test case I don't claim to fully understand all the intricies of C++11, but the following smells fishy to me. I am using a combination of features: 1. The = default syntax to restore implicit constructors/assignments that were otherwise hidden (e.g. default constructor when there are no user-defined constructors), in a templated class. 2. "extern template" in the header to suppress instantiation of a specific instance, with an explicit instantiation in one translation unit. In some cases (I assume depending on compiler eliding) this causes a link-time error for the defaulted constructor. I have attached a minimal test case. I don't know whether there is supposed to be a symbol or whether the compiler is supposed to inline the default implementation, but currently there is a mismatch. System information: Ubuntu 12.04 with gcc version 4.8.1 (Ubuntu 4.8.1-2ubuntu1~12.04) Output (there's a more detailed log in the attachment with -v -save-temps): g++-4.8 -std=c++11 -c defaulted.cpp g++-4.8 -std=c++11 -c impl.cpp g++-4.8 -std=c++11 -o defaulted defaulted.o impl.o defaulted.o: In function `main': defaulted.cpp:(.text+0x10): undefined reference to `A::A()' collect2: error: ld returned 1 exit status make: *** [defaulted] Error 1