This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11367] undefined references for static template member functions


------- Additional Comments From richard dot kreckel at ginac dot de  2003-06-29 10:12 -------
[Err, I pressed Enter too early, here follows the description.  Sorry.]

Consider this piece of code:

template <typename T>
struct managed {
    bool (*_gc_fun) (void*);  // A hook for garbage collection
    T data;
    managed (const T& t) : _gc_fun (no_gc), data(t) { }
    ~managed () { }
    // How can we force GCC-3.4 to emit code for this one when a constructor
    // is present?  Moving it out of the class definition doesn't help.
    static bool no_gc (void*) { return false; }

int main()
    managed<int>* ht = new managed<int>( 42 );
    delete ht;

Using the current mainline, i.e. 3.4 20030628 (experimental) one gets
"undefined reference to `managed<int>::no_gc(void*)'" at link-time.

GCC-3.3 and earlier all used to produce a weak symbol resulting in a working

The above piece of code was extracted while trying to port the CLN library
<> to the current mainline.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]