This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/25915] New: instantiated templates with anonymous classes as arguments should be static
- From: "sabre at nondot dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Jan 2006 23:56:43 -0000
- Subject: [Bug c++/25915] New: instantiated templates with anonymous classes as arguments should be static
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider:
---
template <typename foo>
void bar() {}
namespace { class C {};}
void (*FP)() = bar<C>;
---
Because 'bar' is instantiated with 'C', a class in an anonymous namespace, this
instantiation can never be shared across other translation units. As such, it
should be marked static, to improve static and dynamic link times and improve
future IPO potential.
On PPC Darwin, the instantion of bar turns into:
.section __TEXT,__textcoal_nt,coalesced,no_toc
.align 2
.weak_definition __Z3barIN21_GLOBAL__N_t.cczMkGAb1CEEvv
.private_extern __Z3barIN21_GLOBAL__N_t.cczMkGAb1CEEvv
.section __TEXT,__textcoal_nt,coalesced,no_toc
.align 2
__Z3barIN21_GLOBAL__N_t.cczMkGAb1CEEvv:
blr
-Chris
--
Summary: instantiated templates with anonymous classes as
arguments should be static
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sabre at nondot dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25915