From b8f968b6e45816d3f5148eb3fb9e10803fedd3f9 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 29 Jun 2021 23:35:02 +0800 Subject: [PATCH] make our fix parallel to the patch sent upstream remove const generics so we don't affect their mininum rust version requirement --- src/scalar.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/scalar.rs b/src/scalar.rs index 2963e79..b6d03e3 100644 --- a/src/scalar.rs +++ b/src/scalar.rs @@ -915,8 +915,11 @@ impl Scalar { let mut naf = [0i8; 256]; + // work-around for https://github.com/rust-lang/rust/issues/86693 + // riscv32i targets mis-align u64 types, leading to the lower 32 bits being aliased to the upper 32 bits + // the AlignedU64Slice wrapper forces the enclosed structure to be aligned, thus avoiding this problem. #[repr(align(32))] - struct AlignedU64Slice([u64; N]); + struct AlignedU64Slice([u64; 5]); let mut x_u64 = AlignedU64Slice([0u64; 5]); LittleEndian::read_u64_into(&self.bytes, &mut x_u64.0[0..4]);