[Bug c++/11367] undefined references for static template member functions
richard dot kreckel at ginac dot de
gcc-bugzilla@gcc.gnu.org
Sun Jun 29 10:12:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11367
------- 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
program.
The above piece of code was extracted while trying to port the CLN library
<http://www.ginac.de/CLN/> to the current mainline.
More information about the Gcc-bugs
mailing list