http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52688
Bug #: 52688 Summary: static local variable can accessed from local class of function template Classification: Unclassified Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: sir_nawaz...@yahoo.com As per the C++ specification, static local variable can be accessed from local class of function template, but GCC 4.6.1 gives error for the following code-snippet: template<typename T> T f() { static const double staticLocalVariable = 100.0; struct local { static double f() { return staticLocalVariable; } }; return T(local::f()); } int main() { std::cout << f<double>() << std::endl; } While gcc-4.5.1 compiles fine this code, gcc-4.6.1 gives error, saying: undefined reference to `staticLocalVariable'