This may be related to PR25868, but looks simpler. Take this piece of code that certainly looks valid to me: ---------------------- template <int dim> class X {};
template <class T> class Y { static const unsigned int dim = 1; X<dim> f(); }; template <class T> X<Y<T>::dim> Y<T>::f() { return X<dim>(); } --------------------- We reject the code with 3.3, 3.4, 4.0, 4.1, and mainline. I don't have any older compilers here to check prior versions. The message is this: ----------------- g/y> ~/tmp/build/gcc/mainline/bin/c++ -c x.cc x.cc:12: error: prototype for 'X<Y<T>::dim> Y<T>::f()' does not match any in class 'Y<T>' x.cc:8: error: candidate is: X<1> Y<T>::f() x.cc:12: error: template definition of non-template 'X<Y<T>::dim> Y<T>::f()' ----------------- Since Y<T>::dim == 1, the function really does match its prototype, despite the error. So this is a rejects-valid. W. -- Summary: Rejects template with local static variable used in return type Product: gcc Version: 4.1.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bangerth at dealii dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26261