http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51936
Bug #: 51936 Summary: template function not instantiated Classification: Unclassified Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: blaffabla...@gmail.com Created attachment 26405 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26405 test case It appears that in some circumstances g++ fails to instantiate a template function, and so end up in link time errors. Consider the code in attachment. If compiled with: g++ -Wall -std=c++0x testcase.cpp the result is: testcase.cpp:(.text+0x13): undefined reference to `int asd<int, 0>(int*)' collect2: ld returned 1 exit status whereas if compiled with: g++ -Wall -std=c++0x -DWORKAROUND testcase.cpp it does warn for the unused variable 'inted', but compiles and run correctly. It looks like that getting the pointer of a template function and immediately cast it to something else "weakens" the usage of the template, so that g++ doesn't instantiate it.