
Simon Atanasyan wrote:
% cat test.cc static int bar(int) { return 0; }
template <typename T> int foo(T arg) { return bar(arg); }
int main() { return foo(1); }
% CC -V test.cc CC: Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25 ccfe: Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25 "test.cc", line 9: Error: Reference to static bar(int) not allowed in template foo<int>(int), try using -features=tmplrefstatic. "test.cc", line 14: Where: While instantiating "foo<int>(int)". "test.cc", line 14: Where: Instantiated from non-template code. 1 Error(s) detected.
I'd like to note that the code is valid right until foo is instantiated in more than one translation unit. So the compiler restriction might not be a bad idea after all.