Hi Jonathan, I don´t think this link applies. It is clear that linking will fail in the link examples because the static variables are declared but never defined, i.e. they are never instantiated. On the other hand the difference between the non working versions std::cout << (b = aa< X<4> >(3))[1].v << std::endl; or the even shorter version std::cout << aa< X<4> >(3)[1].v << std::endl; and the working version b = aa< X<4> >(3); std::cout << b[1].v << std::endl; is the presence of an intermediate assignment acting as a temporary variable. The behavior cannot be different. Or conversely if the former versions didn´t work, then the last version shouldn´t either. Best, Mattia On 2/15/12, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote: > On 15/02/2012, Mattia Jona-Lasinio <mattia.jona@xxxxxxxxx> wrote: >> Hi list, >> >> the following code does not link with g++ 4.3.2 but works with the >> intel compiler version 11.0 >> >> #include <iostream> >> >> template <int T = 5> >> struct X >> { >> static const int v = T*X<T-1>::v; >> }; >> >> template <> >> struct X<0> >> { >> static const int v = 1; >> }; >> >> template <typename T> >> T *aa(int n) >> { >> return (new T[n]); >> } >> >> int main() >> { >> X<4> *b; >> >> std::cout << (b = aa< X<4> >(3))[1].v << std::endl; // relevant line >> >> delete[] b; >> >> return 0; >> } >> >> Also the following shorter version does not link with g++ >> >> int main() >> { >> std::cout << aa< X<4> >(3)[1].v << std::endl; // relevant line >> >> return 0; >> } >> >> while the following version links with g++ though all versions must be >> equivalent. Am I missing something? >> >> int main() >> { >> X<4> *b; >> >> b = aa< X<4> >(3); // relevant line >> std::cout << b[1].v << std::endl; // relevant line >> >> delete[] b; >> >> return 0; >> } >> >> > > Is this > http://gcc.gnu.org/wiki/VerboseDiagnostics#undefined_reference_to_.60S::a.27 >