Boost logo

Boost :

Subject: [boost] [typeof] Weird VC++ compiler bug
From: Edward Diener (eldiener_at_[hidden])
Date: 2015-05-22 10:02:00


I discovered a strange VC++ bug using Boost.typeof. I am not posting
this to rag VC++ but wondering if there is some known workaround in
Boost or in Boost.config.

   #include <boost/typeof/typeof.hpp>

   template <class T>
   struct dereference
     {
     typedef BOOST_TYPEOF_TPL(*T()) type;
     };

   int main()
     {
     }

Compiling this with VC++12 gives:

test_vc_type_of_indirection.cpp(6) : error C2100: illegal indirection
         test_vc_type_of_indirection.cpp(7) : see reference to class
template instantiation 'dereference<T>' being compiled

Notice that I am not even instantiating 'dereference'.

But if I write:

   #include <boost/typeof/typeof.hpp>

   template <class T>
   struct dereference
     {
     void afunction() { typedef BOOST_TYPEOF_TPL(*T()) type; }
     };

   int main()
     {
     }

all is well, for all the good it does me.

BOOST_TYPEOF_TPL(*T()) expands to:

typename
boost::type_of::msvc_typeid_wrapper<sizeof(*boost::type_of::encode_start(*T()))>::type

and if I substitute this directly the same results occur.

I can report this to the VC++ bug tracker but wanted to see if this is a
known problem with VC++ in Boost, some weird error for which maybe Boost
has some workaround syntax.


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