From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1827 invoked by alias); 15 Nov 2012 20:57:06 -0000 Received: (qmail 1763 invoked by uid 48); 15 Nov 2012 20:56:47 -0000 From: "luto at mit dot edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55347] New: Specialized member of class template prevents visibility setting Date: Thu, 15 Nov 2012 20:57: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-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: luto at mit dot edu 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: 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: 2012-11/txt/msg01454.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55347 Bug #: 55347 Summary: Specialized member of class template prevents visibility setting Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: luto@mit.edu Compiling this code: --- cut here --- template class A { void func() {} }; //#pragma GCC visibility push(default) -- no effect template<> void A::func() {} // This causes a problem template class __attribute__((visibility("default"))) A; //#pragma GCC visibility pop --- cut here --- results in: template_visibility.cc:10:55: warning: type attributes ignored after type is already defined [-Wattributes] The emitted code ends up hidden. This is a minor issue in C++98 (I'm not sure why you'd want to do this), but it's an actual problem in C++11: extern templates behave the same way. I think that gcc's behavior is consistent, but there should be a way to override the visibility of a particular class template specialization *without instantiating/defining it*, then specialize a member, then instantiate the template.