According to this answer, since C++17, even if a pointer has the right address and the right type dereferencing it can cause undefined behaviour.
align
No. The bytes constituting the int
object p2
points to are not reachable through p1+1
.
The "reachable" rule basically means that launder
doesn't allow you to access storage you can't legally access via the original pointer. Since an opaque function may launder
pointers as much as it wants, permitting this kind of shenanigans would substantially inhibit escape analysis.