/* * Compile with: cl -MD -I. -EHsc -O2 tt_failure.cpp * * tt_failure.cpp * .\boost/type_traits/type_with_alignment.hpp(206) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE' * with * [ * x=false * ] * .\boost/type_traits/type_with_alignment.hpp(218) : see reference to class template instantiation 'boost::detail::type_with_alignment_imp' being compiled * with * [ * Align=12 * ] * tt_failure.cpp(36) : see reference to class template instantiation 'boost::type_with_alignment' being compiled * with * [ * Align=12 * ] * .\boost/type_traits/type_with_alignment.hpp(207) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE' * with * [ * x=false * ] */ #include #include #include #ifdef _MSC_VER // This kind of packing is set within MSVC 9.0 headers. // E.g. std::ostream has it. #pragma pack(push,8) #endif /* _MSC_VER */ // The issue is gone if Root has no data members struct Root { int a; }; // The issue is gone if Root is inherited non-virtually struct A : virtual public Root {}; #ifdef _MSC_VER #pragma pack(pop) #endif /* _MSC_VER */ // The class gets alignment 12 for some reason // The real-world case that triggered the problem is a user-defined stream class that // derived from std::ostream. Such class could not be used with tools involving type_with_alignment. class my_class : public A { public: // The issue is gone if the type is not a boost::function. The signature doesn't matter. typedef boost::function0< void > function_type; function_type m_function; }; int main(int, char*[]) { boost::type_with_alignment< boost::alignment_of< my_class >::value >::type obj; return static_cast< int >(&obj != NULL); }