# Pre-RFC: Allow array stride != size

**URL:** <https://internals.rust-lang.org/t/pre-rfc-allow-array-stride-size/17933>\
**Category:** language design\
**Created:** [December 7, 2022, 9:40pm UTC](https://internals.rust-lang.org/t/pre-rfc-allow-array-stride-size/17933 "2022-12-07T21:40:05Z")\
**Posts on this page:** 1\
**Showing post:** 35

<div class="post-metadata">

**Author:** ![SkiFire13](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/skifire13/32/7579_2.png) [@SkiFire13](https://internals.rust-lang.org/u/SkiFire13)\
**Post date:** [January 16, 2023, 5:45pm UTC](https://internals.rust-lang.org/t/pre-rfc-allow-array-stride-size/17933/35 "2023-01-16T17:45:48Z")

</div>

The problem is that given a `&mut Nested` the current expectation is to be able to write `std::mem::size_of::<Nested>()` bytes to it, which include the padding bytes. However with your approach `flag` is placed in `n`'s padding byte, which mean you would end up writing garbage/invalid values to it, which is UB!

And you could argue that you could make `Nested`'s size equal to 7 as to not include the padding byte where `flag` is placed, but another expectation is that elements of slices are placed at an offset multiple of the element size. But if `Nested`'s size is 7 then the second element of a `[Nested]` would end up at offset 7, which is not aligned, and thus UB again.

---

_[View the full topic](https://internals.rust-lang.org/t/pre-rfc-allow-array-stride-size/17933)._
