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

Reply via email to