Fixes #206 ("operator-> on static_vector::iterator causes cast alignment warning")

This commit is contained in:
Ion Gaztañaga
2021-12-28 15:17:15 +01:00
parent ea3521bf14
commit 3f76f9fdf7
23 changed files with 124 additions and 93 deletions

View File

@@ -14,6 +14,7 @@
#include <boost/container/uses_allocator.hpp>
#include <boost/container/detail/mpl.hpp>
#include <boost/move/core.hpp>
#include <boost/move/detail/force_ptr.hpp>
template<class T, unsigned int Id, bool HasTrueTypes = false>
class propagation_test_allocator
@@ -69,7 +70,7 @@ class propagation_test_allocator
{ return std::size_t(-1); }
T* allocate(std::size_t n)
{ return (T*)::new char[n*sizeof(T)]; }
{ return boost::move_detail::force_ptr<T*>(::new char[n*sizeof(T)]); }
void deallocate(T*p, std::size_t)
{ delete []static_cast<char*>(static_cast<void*>(p)); }

View File

@@ -13,6 +13,7 @@
#include <boost/container/detail/config_begin.hpp>
#include <boost/container/throw_exception.hpp>
#include <boost/move/detail/force_ptr.hpp>
#include <cstddef>
@@ -77,7 +78,7 @@ class default_init_allocator
puc_raw[i] = static_cast<unsigned char>(s_pattern--);
}
}
return (Integral*)puc_raw;;
return move_detail::force_ptr<Integral*>(puc_raw);
}
void deallocate(Integral *p, std::size_t)

View File

@@ -34,7 +34,7 @@
#include <boost/move/utility_core.hpp>
#include <boost/move/adl_move_swap.hpp>
#include <boost/move/detail/force_ptr.hpp>
#include <boost/assert.hpp>
#include <memory>
@@ -61,7 +61,7 @@ class simple_allocator
{}
T* allocate(std::size_t n)
{ return (T*)::new char[sizeof(T)*n]; }
{ return move_detail::force_ptr<T*>(::new char[sizeof(T)*n]); }
void deallocate(T*p, std::size_t)
{ delete[] ((char*)p);}
@@ -176,7 +176,7 @@ class propagation_test_allocator
{ unique_id_ = id; }
T* allocate(std::size_t n)
{ return (T*)::new char[sizeof(T)*n]; }
{ return move_detail::force_ptr<T*>(::new char[sizeof(T)*n]); }
void deallocate(T*p, std::size_t)
{ delete[] ((char*)p);}

View File

@@ -17,6 +17,7 @@
#include <boost/container/detail/mpl.hpp>
#include <boost/move/utility_core.hpp>
#include <boost/container/detail/type_traits.hpp>
#include <boost/move/detail/force_ptr.hpp> //adl_move_swap
namespace boost{
namespace container {
@@ -151,7 +152,7 @@ static boost::container::dtl::aligned_storage<sizeof(EmplaceIntPair)*10>::type p
static EmplaceIntPair* initialize_emplace_int_pair()
{
EmplaceIntPair* ret = reinterpret_cast<EmplaceIntPair*>(&pair_storage);
EmplaceIntPair* ret = move_detail::force_ptr<EmplaceIntPair*>(&pair_storage);
for(unsigned int i = 0; i != 10; ++i){
new(&ret->first)EmplaceInt();
new(&ret->second)EmplaceInt();

View File

@@ -19,6 +19,7 @@
#include <boost/container/detail/algorithm.hpp> //equal()
#include "movable_int.hpp"
#include <boost/move/make_unique.hpp>
#include <boost/move/detail/force_ptr.hpp>
namespace boost { namespace container { namespace test {
@@ -85,7 +86,7 @@ bool test_insert_with_expand_bwd()
{
boost::movelib::unique_ptr<char[]> memptr =
boost::movelib::make_unique_definit<char[]>(MemorySize*sizeof(value_type));
value_type *memory = (value_type*)memptr.get();
value_type *memory = move_detail::force_ptr<value_type*>(memptr.get());
std::vector<value_type> initial_data;
initial_data.resize(InitialSize[iteration]);
for(unsigned int i = 0; i < InitialSize[iteration]; ++i){
@@ -148,7 +149,7 @@ bool test_assign_with_expand_bwd()
{
boost::movelib::unique_ptr<char[]> memptr =
boost::movelib::make_unique_definit<char[]>(MemorySize*sizeof(value_type));
value_type *memory = (value_type*)memptr.get();
value_type *memory = move_detail::force_ptr<value_type*>(memptr.get());
//Create initial data
std::vector<value_type> initial_data;
initial_data.resize(InitialSize[iteration]);

View File

@@ -22,6 +22,7 @@ volatile ::boost::container::vector<empty> dummy;
#include <boost/container/allocator.hpp>
#include "movable_int.hpp"
#include "dummy_test_allocator.hpp"
#include <boost/move/detail/force_ptr.hpp>
class CustomAllocator
{
@@ -33,7 +34,7 @@ class CustomAllocator
typedef short difference_type;
pointer allocate(size_type count)
{ return (pointer)new char[sizeof(value_type)*count]; }
{ return boost::move_detail::force_ptr<pointer>(new char[sizeof(value_type)*count]); }
void deallocate(pointer ptr, size_type )
{ delete [](char*)ptr; }