Boost logo

Boost Users :

Subject: [Boost-users] [boost-users] VC2005 - strange bug (when specializing base template)
From: Igor R (boost.lists_at_[hidden])
Date: 2008-11-13 08:04:58


This is not a boost-related issue (except the fact that enable_if is
used), but it might be of interest to the boost-users community.
The following bug was detected in some compicated environment, but the
following seems to be the minimal construct where it appears (compile
in Debug mode; see comments in Test::func() ).

// main.cpp
#include <boost/type_traits/is_integral.hpp>
#include <boost/utility.hpp>

class BasicVersion

template<typename Param, class Enable = void> class Version1 : public
  Version1() : verData_(2)
  void go()
    verData_ = 3;
  int verData_;

template<typename Param, class Enable = void> class TestBase
template<typename Param> class TestBase<Param, typename
boost::enable_if<boost::is_integral<Param> >::type> : public

template<class Param> class Test : private boost::noncopyable, public
  void func()
    go(); // This works well
    TestBase::go(); // This jumps to an incorrect place (bad "this"),
verData_ contains garbage

    the following code is generated for the previous 2 calls:
004116D3 mov ecx,dword ptr [this]
004116D6 add ecx,4
004116D9 call Version1<int,void>::go (4110F5h)
004116DE mov ecx,dword ptr [this]
004116E1 add ecx,8
004116E4 call Version1<int,void>::go (4110F5h)

  int data_;

int main()
  Test<int> test;

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at