diff --git a/include/boost/type_index/ctti_type_index.hpp b/include/boost/type_index/ctti_type_index.hpp index b181854..3d543e2 100644 --- a/include/boost/type_index/ctti_type_index.hpp +++ b/include/boost/type_index/ctti_type_index.hpp @@ -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(boost::detail::ctti::n()); } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 9775ba7..8690b14 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -40,6 +40,7 @@ test-suite type_index [ run testing_crossmodule.cpp test_lib_nortti $(tlib) : : : 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 ] diff --git a/test/type_index_test_ctti_alignment.cpp b/test/type_index_test_ctti_alignment.cpp new file mode 100644 index 0000000..b2f57d2 --- /dev/null +++ b/test/type_index_test_ctti_alignment.cpp @@ -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 +#include + +int main() { + BOOST_STATIC_ASSERT_MSG( + boost::alignment_of::value == boost::alignment_of::value, + "Alignments of boost::typeind::detail::ctti_data and char differ. " + "It is unsafe to reinterpret_cast between them." + ); +} +