Boost logo

Boost :

Subject: Re: [boost] [config] vc10 and BOOST_NO_DECLTYPE
From: Peter Dimov (pdimov_at_[hidden])
Date: 2010-04-06 19:53:50


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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk