workaround for a GCC 4.2 compiler bug and warning in pointer conversion,

fixes Issue 615, thanks to Daniel Sefton for the report
This commit is contained in:
erwin.coumans
2012-03-30 19:15:55 +00:00
parent 4b92fbaccf
commit 8453942546

View File

@@ -521,19 +521,27 @@ struct btTypedObject
};
///align a pointer to the provided alignment, upwards
template <typename T>T* btAlignPointer(T* unalignedPtr, size_t alignment)
{
union
{
T* ptr;
size_t integer;
};
const size_t bit_mask = ~(alignment - 1);
ptr = unalignedPtr;
integer += alignment-1;
integer &= bit_mask;
return ptr;
struct btConvertPointerSizeT
{
union
{
T* ptr;
size_t integer;
};
};
btConvertPointerSizeT converter;
const size_t bit_mask = ~(alignment - 1);
converter.ptr = unalignedPtr;
converter.integer += alignment-1;
converter.integer &= bit_mask;
return converter.ptr;
}
#endif //BT_SCALAR_H