forked from boostorg/type_index
Added test to ensure that alignments of ctti_data and char are same
This commit is contained in:
@@ -63,6 +63,8 @@ inline const detail::ctti_data& ctti_construct() BOOST_NOEXCEPT {
|
||||
// “pointer to T1” to the type “pointer to T2” (where T1 and T2 are object types and where the alignment
|
||||
// requirements of T2 are no stricter than those of T1) and back to its original type yields the original pointer
|
||||
// value.
|
||||
//
|
||||
// Alignments are checked in `type_index_test_ctti_alignment.cpp` test.
|
||||
return *reinterpret_cast<const detail::ctti_data*>(boost::detail::ctti<T>::n());
|
||||
}
|
||||
|
||||
|
@@ -40,6 +40,7 @@ test-suite type_index
|
||||
[ run testing_crossmodule.cpp test_lib_nortti $(tlib) : : : <rtti>off : testing_crossmodule_no_rtti ]
|
||||
[ compile-fail type_index_test_ctti_copy_fail.cpp ]
|
||||
[ compile-fail type_index_test_ctti_construct_fail.cpp ]
|
||||
[ compile type_index_test_ctti_alignment.cpp ]
|
||||
|
||||
# Mixing RTTI on and off
|
||||
[ link-fail testing_crossmodule.cpp $(tlib) test_lib_rtti : $(nortti) : link_fail_nortti_rtti ]
|
||||
|
18
test/type_index_test_ctti_alignment.cpp
Normal file
18
test/type_index_test_ctti_alignment.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Copyright Antony Polukhin, 2012-2013.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/type_index/ctti_type_index.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
|
||||
int main() {
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
boost::alignment_of<boost::typeind::detail::ctti_data>::value == boost::alignment_of<char>::value,
|
||||
"Alignments of boost::typeind::detail::ctti_data and char differ. "
|
||||
"It is unsafe to reinterpret_cast between them."
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user