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