[Pre-RFC] Add a new offset_of macro to core::mem

Oh and did you think we were not aware of union-transmutes in CTFE and we’d close that loophole if you reported it? Don’t worry, we knew for a while. :wink: It had to stay open due to backwards compatibility.

I have to admit I am slightly irritated at the idea that some people would not report known soundness issues because they are afraid they would get fixed. I hope I did not give the impression that when a soundness issue occurs, it will be closed and shut at all cost and disregard valid concerns. I am well aware that there are trade-offs here, and while I personally feel very strongly about soundness, I sympasize with developers that just need to “get something done”. I am sorry if I came across as overly dogmatic in that regard.

I do think that developers should be upfront about deliberately causing UB and the reasons for that. I have submitted PRs to several projects that add comments saying “this is UB, but we do it anyway because”. Whenever that happens, that’s a great piece of feedback for things the language should be able to do but currently isn’t. We should probably collect these somewhere!

6 Likes