Stream: t-compiler/help

Topic: Safety contract for `ptr::align_offset`

LeSeulArtichaut (Jun 25 2020 at 18:16, on Zulip):

I was writing safety comments for #73622 and need to prove safety when using ptr::align_offset. However, I wasn't able to find any information about its safety contract in its documentation. Can someone help me? cc @nagisa

nagisa (Jun 25 2020 at 23:05, on Zulip):

align_offset is not unsafe, though?

nagisa (Jun 25 2020 at 23:05, on Zulip):

align_to is, but that's because it effectively transmutes T to U.

nagisa (Jun 25 2020 at 23:08, on Zulip):

Oh, I guess you may be referring to the align_offset that ptr::align_offset calls?

nagisa (Jun 25 2020 at 23:11, on Zulip):

In that case the implementation here requires that alignment is a power of two, as this is not checked.

Last update: Sep 28 2020 at 14:30UTC