Boost logo

Boost Users :

From: Andrew n marshall (amarshal_at_[hidden])
Date: 2005-12-10 22:55:20


I've encountered a problem when transitioning from Boost.Test 1.32 to
1.33. New to 1.33 is a set_precision(..) method on the print_log_value
functor (in test_tools.hpp). The problem, as I see it, is the use of
numeric_limits<T>, which exposes the assumption T is a numeric entity at
all. I'm actually surprised it compiles as often as it does, so maybe
my blame is misdirected. Nonetheless, I was able to create the attached
test case to prove my point. I've also included the generated build log
with the really nasty compile time error.

Anm


// Weird Compile problem with Boost.Test 1.33

#include <iostream>
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;

// Class heirarchy and support functions
class Abstract {
        virtual void go() = 0; // If Abstract is not pure virtual, everything compiles fine
};
class Concrete : public Abstract {
        virtual void go() { }
};

inline bool operator== ( const Abstract& a, const Abstract& b ) {
        return &a == &b; // identity
}

template <class C, class T > // character type, traits
inline std::basic_ostream<C,T>& operator<< ( std::basic_ostream<C,T>& out, const Abstract& a ) {
        // Just prints a memory address.
        return out << "Abstract_at_0x" << &a;
}

// Function that forces us to work with the abstract interface
Abstract& generalize( Concrete& c ) {
        return c;
}

// Test case & suite
void test_abstract_identity() {
        Concrete a, b;
        // These work
        BOOST_CHECK_EQUAL( a, a ); // works
        BOOST_CHECK_EQUAL( a, b ); // fails correctly

        // These won't compile with 1.33 & VC++7.1
        BOOST_CHECK_EQUAL( generalize(a), a );
        Abstract& c = a;
        BOOST_CHECK_EQUAL( a, c );
}

test_suite*
init_unit_test_suite( int, char* [] ) {
    test_suite* test= BOOST_TEST_SUITE( "Example failure of Boost.Test 1.33.0" );
        test->add( BOOST_TEST_CASE( &test_abstract_identity ), 1 );
        return test;
}

// EOF


Build Log
  

------- Build started: Project: Boost.Test-test, Configuration: Debug|Win32 -------

Command Lines
  
Creating temporary file "d:\Projects\Saso\sandbox\saso\core\smartbody\motionengine\visualc7-boost1_33\obj\Boost.Test-test_debug\RSP000018.rsp" with contents
[
/Od /I "..\include\\" /I "D:\local\lib\boost_1_33_0" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "BOOST_TEST_NO_AUTO_LINK" /D "_MBCS" /Gm /EHsc /RTC1 /MDd /GS /Fo".\obj\Boost.Test-test_debug/" /Fd".\obj\Boost.Test-test_debug/vc70.pdb" /W3 /c /Wp64 /ZI /TP
"\Projects\Saso\sandbox\saso\core\smartbody\motionengine\src\test\BoostTest-test.cpp"
]
Creating command line "cl.exe @"d:\Projects\Saso\sandbox\saso\core\smartbody\motionengine\visualc7-boost1_33\obj\Boost.Test-test_debug\RSP000018.rsp" /nologo"
Output Window
  
Compiling...
BoostTest-test.cpp
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\limits(75) : error C2259: 'Abstract' : cannot instantiate abstract class
        due to following members:
        'void Abstract::go(void)' : pure virtual function was not defined
        d:\Projects\SASO\sandbox\saso\core\smartbody\motionengine\src\test\BoostTest-test.cpp(10) : see declaration of 'Abstract::go'
        d:\local\lib\boost_1_33_0\boost\test\test_tools.hpp(279) : see reference to class template instantiation 'std::numeric_limits<_Ty>' being compiled
        with
        [
            _Ty=Abstract
        ]
        d:\local\lib\boost_1_33_0\boost\test\test_tools.hpp(278) : while compiling class-template member function 'void boost::test_tools::tt_detail::print_log_value::set_precision(std::ostream &,boost::mpl::false_)'
        with
        [
            T=Abstract
        ]
        d:\local\lib\boost_1_33_0\boost\test\test_tools.hpp(372) : see reference to class template instantiation 'boost::test_tools::tt_detail::print_log_value' being compiled
        with
        [
            T=Abstract
        ]
        d:\local\lib\boost_1_33_0\boost\test\utils\wrap_stringstream.hpp(66) : see reference to function template instantiation 'std::ostream &boost::test_tools::tt_detail::operator <<(std::ostream &,const boost::test_tools::tt_detail::print_helper_t &)' being compiled
        with
        [
            Arg0=Abstract,
            T=Abstract
        ]
        d:\local\lib\boost_1_33_0\boost\test\test_tools.hpp(427) : see reference to function template instantiation 'boost::basic_wrap_stringstream &boost::operator <<>(boost::basic_wrap_stringstream &,const boost::test_tools::tt_detail::print_helper_t &)' being compiled
        with
        [
            CharT=char,
            T=Abstract
        ]
        d:\Projects\SASO\sandbox\saso\core\smartbody\motionengine\src\test\BoostTest-test.cpp(39) : see reference to function template instantiation 'void boost::test_tools::tt_detail::check_frwd(Pred,boost::wrap_stringstream &,boost::test_tools::const_string,size_t,boost::test_tools::tt_detail::tool_level,boost::test_tools::tt_detail::check_type,const Arg0 &,const char *,const Arg1 &,const char *)' being compiled
        with
        [
            Pred=boost::test_tools::tt_detail::equal_impl_frwd,
            Arg0=Abstract,
            Arg1=Concrete
        ]
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\limits(80) : error C2259: 'Abstract' : cannot instantiate abstract class
        due to following members:
        'void Abstract::go(void)' : pure virtual function was not defined
        d:\Projects\SASO\sandbox\saso\core\smartbody\motionengine\src\test\BoostTest-test.cpp(10) : see declaration of 'Abstract::go'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\limits(86) : error C2259: 'Abstract' : cannot instantiate abstract class
        due to following members:
        'void Abstract::go(void)' : pure virtual function was not defined
        d:\Projects\SASO\sandbox\saso\core\smartbody\motionengine\src\test\BoostTest-test.cpp(10) : see declaration of 'Abstract::go'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\limits(91) : error C2259: 'Abstract' : cannot instantiate abstract class
        due to following members:
        'void Abstract::go(void)' : pure virtual function was not defined
        d:\Projects\SASO\sandbox\saso\core\smartbody\motionengine\src\test\BoostTest-test.cpp(10) : see declaration of 'Abstract::go'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\limits(96) : error C2259: 'Abstract' : cannot instantiate abstract class
        due to following members:
        'void Abstract::go(void)' : pure virtual function was not defined
        d:\Projects\SASO\sandbox\saso\core\smartbody\motionengine\src\test\BoostTest-test.cpp(10) : see declaration of 'Abstract::go'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\limits(101) : error C2259: 'Abstract' : cannot instantiate abstract class
        due to following members:
        'void Abstract::go(void)' : pure virtual function was not defined
        d:\Projects\SASO\sandbox\saso\core\smartbody\motionengine\src\test\BoostTest-test.cpp(10) : see declaration of 'Abstract::go'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\limits(106) : error C2259: 'Abstract' : cannot instantiate abstract class
        due to following members:
        'void Abstract::go(void)' : pure virtual function was not defined
        d:\Projects\SASO\sandbox\saso\core\smartbody\motionengine\src\test\BoostTest-test.cpp(10) : see declaration of 'Abstract::go'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\limits(111) : error C2259: 'Abstract' : cannot instantiate abstract class
        due to following members:
        'void Abstract::go(void)' : pure virtual function was not defined
        d:\Projects\SASO\sandbox\saso\core\smartbody\motionengine\src\test\BoostTest-test.cpp(10) : see declaration of 'Abstract::go'
Results
  
Build log was saved at "file://d:\Projects\Saso\sandbox\saso\core\smartbody\motionengine\visualc7-boost1_33\obj\Boost.Test-test_debug\BuildLog.htm"
Boost.Test-test - 8 error(s), 0 warning(s)

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net