Closed
Description
I tried this code:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=f4ee5c373508bcb37be6cda3bb627b87
#![feature(repr_simd)]
use core::alloc::Layout;
#[repr(simd)]
struct Simd<T, const N: usize>(pub [T; N]);
fn main() {
assert_eq!(
Layout::new::<Simd<i8, 3>>(),
Layout::from_size_align(3, 1).unwrap()
);
}
I expected to see this happen: run with no errors because Simd<T, N>
types should be the same size as the corresponding array type [T; N]
(something we unofficially agreed on iirc, but is not formally decided)
Instead, this happened:
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `Layout { size: 4, align: 4 (1 << 2) }`,
right: `Layout { size: 3, align: 1 (1 << 0) }`', src/main.rs:7:5
Meta
rustc --version --verbose
:
<current nightly as of issue creation -- probably 2022-11-29 nightly>
crate version in Cargo.toml
:
N/A