Boost logo

Boost :

Subject: Re: [boost] [config] vc10 and BOOST_NO_DECLTYPE
From: Eric Niebler (eric_at_[hidden])
Date: 2010-04-06 15:58:59


On 4/6/2010 12:49 PM, Eric Niebler wrote:
> The issue is whether the decltype keyword is too broken on VC10 to
> define BOOST_NO_DECLTYPE. I think it /may/ be, so we should define it
> just to be safe, at least for 1.43.
>

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>()); }

     // The following, which should be equivalent, compiles without
     // problem:
     //S<pair<T,T> > foo() { return wrap(pair<T,T>()); }
   };

   int main()
   {
     S<int> s;
   }

If these are both conforming implementations of decltype, that's bad
news. It means that std::result_of has a significant and unfortunate
change of behavior from tr1::result_of and boost::result_of, and also
means that decltype cannot be safely used in all contexts.

I think we need a decltype expert to weigh in on this. I may bring the
issue up with the std committee.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

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