@@ -28,8 +28,8 @@ namespace snmalloc
2828 inline U* pointer_offset (T* base, size_t diff)
2929 {
3030 SNMALLOC_ASSERT (base != nullptr ); /* Avoid UB */
31- return reinterpret_cast <U* >(
32- reinterpret_cast < uintptr_t >(base) + static_cast <uintptr_t >(diff));
31+ return unsafe_from_uintptr<U >(
32+ unsafe_to_uintptr<T >(base) + static_cast <uintptr_t >(diff));
3333 }
3434
3535 template <SNMALLOC_CONCEPT (capptr::ConceptBound) bounds, typename T>
@@ -129,8 +129,8 @@ namespace snmalloc
129129 template <size_t alignment, typename T = void >
130130 inline T* pointer_align_down (void * p)
131131 {
132- return reinterpret_cast <T* >(
133- pointer_align_down<alignment>(reinterpret_cast < uintptr_t >(p)));
132+ return unsafe_from_uintptr<T >(
133+ pointer_align_down<alignment>(unsafe_to_uintptr< void >(p)));
134134 }
135135
136136 template <
@@ -164,8 +164,8 @@ namespace snmalloc
164164#if __has_builtin(__builtin_align_up)
165165 return static_cast <T*>(__builtin_align_up (p, alignment));
166166#else
167- return reinterpret_cast <T* >(
168- bits::align_up (reinterpret_cast < uintptr_t >(p), alignment));
167+ return unsafe_from_uintptr<T >(
168+ bits::align_up (unsafe_to_uintptr< void >(p), alignment));
169169#endif
170170 }
171171 }
@@ -197,8 +197,8 @@ namespace snmalloc
197197#if __has_builtin(__builtin_align_down)
198198 return static_cast <T*>(__builtin_align_down (p, alignment));
199199#else
200- return reinterpret_cast <T* >(
201- bits::align_down (reinterpret_cast < uintptr_t >(p), alignment));
200+ return unsafe_from_uintptr<T >(
201+ bits::align_down (unsafe_to_uintptr< void >(p), alignment));
202202#endif
203203 }
204204
@@ -221,8 +221,8 @@ namespace snmalloc
221221#if __has_builtin(__builtin_align_up)
222222 return static_cast <T*>(__builtin_align_up (p, alignment));
223223#else
224- return reinterpret_cast <T* >(
225- bits::align_up (reinterpret_cast < uintptr_t >(p), alignment));
224+ return unsafe_from_uintptr<T >(
225+ bits::align_up (unsafe_to_uintptr< void >(p), alignment));
226226#endif
227227 }
228228
0 commit comments