-
Notifications
You must be signed in to change notification settings - Fork 142
Open
Labels
compatibility-nonbreakingChanges that are (likely to be) non-breakingChanges that are (likely to be) non-breaking
Description
We have code like the following in zerocopy as of this writing:
Lines 2323 to 2331 in 27aea67
| /// Is `t` aligned to `mem::align_of::<U>()`? | |
| #[inline(always)] | |
| fn aligned_to<T: AsAddress, U>(t: T) -> bool { | |
| // `mem::align_of::<U>()` is guaranteed to return a non-zero value, which in | |
| // turn guarantees that this mod operation will not panic. | |
| #[allow(clippy::arithmetic_side_effects)] | |
| let remainder = t.addr() % mem::align_of::<U>(); | |
| remainder == 0 | |
| } |
According to rust-lang/rust#62420, there's a small chance that this may be decided to be unsound (and it's not supported during const eval, although there are bigger problems regarding using addresses in const eval). We should figure out whether this is a risk we're comfortable with, and consider how we might mitigate it.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
compatibility-nonbreakingChanges that are (likely to be) non-breakingChanges that are (likely to be) non-breaking