
Eric Niebler wrote:
Actually, I may have been too hasty. I notice the same behavior on recent gcc builds. That is, the following program causes both vc10 and gcc in std=c++0x mode to run out of heap space.
template<class T> struct S;
template<class X, class Y> struct pair {};
template<class T> S<T> wrap(T) { return 0; }
template<class T> struct S { S(int = 0) {}
// The following use of decltype causes the compiler to blow up: decltype(wrap(pair<T,T>())) foo() { return wrap(pair<T,T>()); }
This is a CWG question. I don't think that the compilers need to instantiate the definition of S<pair<int,int>> from within the decltype, but it appears that they do, and the standard may well require them to. The other unevaluated context, sizeof, would instantiate because it needs the size, and if decltype shares the same code, it will too.