Hi, I added some testcases and closed the PRs as fixed for 4.8.0.
Thanks, Paolo. ////////////////////
2013-03-02 Paolo Carlini <paolo.carl...@oracle.com> PR c++/52688 * g++.dg/template/static33.C: New. * g++.dg/template/static34.C: Likewise. PR c++/10291 * g++.dg/template/static35.C: New.
Index: g++.dg/template/static33.C =================================================================== --- g++.dg/template/static33.C (revision 0) +++ g++.dg/template/static33.C (working copy) @@ -0,0 +1,18 @@ +// PR c++/52688 +// { dg-do link } + +template<typename T> +T f() +{ + static const double staticLocalVariable = 100.0; + struct local + { + static double f() { return staticLocalVariable; } + }; + return T(local::f()); +} + +int main() +{ + f<double>(); +} Index: g++.dg/template/static34.C =================================================================== --- g++.dg/template/static34.C (revision 0) +++ g++.dg/template/static34.C (working copy) @@ -0,0 +1,21 @@ +// PR c++/52688 +// { dg-do link } + +template<class T> +struct A { + static bool test() { + static bool value = false; + if (value) + return false; + struct S { + S() { value = true; } + }; + static S s; + return true; + } +}; + +int main() +{ + A<int>::test(); +} Index: g++.dg/template/static35.C =================================================================== --- g++.dg/template/static35.C (revision 0) +++ g++.dg/template/static35.C (working copy) @@ -0,0 +1,21 @@ +// PR c++/10291 +// { dg-do link } + +template <class T> +int foo () +{ + static int i; + + struct S { + int bar () { + return i; + } + } s; + + return s.bar (); +} + +int main () +{ + foo<int>(); +}