http://llvm.org/bugs/show_bug.cgi?id=20825
Reid Kleckner <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |[email protected] Resolution|--- |INVALID --- Comment #1 from Reid Kleckner <[email protected]> --- I think you can forward declare your specialization of the static data member like so: // Start .h template <typename T> class A { public: static const char *info; }; template <> const char *A<int>::info; template <> const char *A<char>::info; extern template class A<int>; extern template class A<char>; // Start .cpp #include <iostream> template <> const char *A<int>::info = "This is int"; template <> const char *A<char>::info = "This is char"; int main(int, char **) { std::cout << "A<int>:" << A<int>::info << "\n"; std::cout << "A<char>:" << A<char>::info << "\n"; return 0; } template class A<int>; template class A<char>; ---- Otherwise, the compiler can do things like inline the generic, unspecialized version of an inline function into your program. Consider: template <typename T> struct A { static int f() { return sizeof(int); } }; extern template struct A<int>; int main() { return A<int>::f(); } After optimizations, main will return 4, even if some other TU contains: template <> int A<int>::f() { return 5; }; This specialization can be similarly forward declared as: template <> int A<int>::f(); -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ LLVMbugs mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs
