From 89f18be48e63c8f86042c42268b80b7ce48cd6ea Mon Sep 17 00:00:00 2001 From: John Maddock Date: Mon, 7 Dec 2009 12:56:29 +0000 Subject: [PATCH] Ooops, original test case invoked very undefined behaviour. [SVN r58215] --- test/aligned_storage_empy_test.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/test/aligned_storage_empy_test.cpp b/test/aligned_storage_empy_test.cpp index 6772cc0..28e9e20 100644 --- a/test/aligned_storage_empy_test.cpp +++ b/test/aligned_storage_empy_test.cpp @@ -22,7 +22,7 @@ namespace struct alignment_implementation1 { boost::detail::aligned_storage::aligned_storage_imp type; - const void* address() const { return this; } + const void* address() const { return type.address(); } }; template< unsigned N, unsigned Alignment > @@ -39,24 +39,24 @@ namespace }; template< unsigned N, class T > - const void* get_address1() + std::ptrdiff_t get_address1() { - alignment_implementation1::value> imp1; - return imp1.address(); + static alignment_implementation1::value> imp1; + return static_cast(imp1.address()) - reinterpret_cast(&imp1); } template< unsigned N, class T > - const void* get_address2() + std::ptrdiff_t get_address2() { - alignment_implementation2::value> imp2; - return imp2.address(); + static alignment_implementation2::value> imp2; + return static_cast(imp2.address()) - reinterpret_cast(&imp2); } template< class T > void check() { - const void* addr1 = get_address1<0,T>(); - const void* addr2 = get_address2<0,T>(); + std::ptrdiff_t addr1 = get_address1<0,T>(); + std::ptrdiff_t addr2 = get_address2<0,T>(); // // @remark: only the empty case differs // @@ -101,6 +101,9 @@ check(); #ifdef BOOST_HAS_MS_INT64 check<__int64>(); #endif +#ifdef BOOST_HAS_LONG_LONG +check(); +#endif check(); check();