calculate MAX_LENGTH_VALUE for 32-bit and 64-bit targets
@@ -46,9 +46,10 @@ pub use encode::{Encode, SszEncoder};
/// The number of bytes used to represent an offset.
pub const BYTES_PER_LENGTH_OFFSET: usize = 4;
/// The maximum value that can be represented using `BYTES_PER_LENGTH_OFFSET`.
-// allows overflow on 32-bit target
-#[allow(const_err)]
-pub const MAX_LENGTH_VALUE: usize = (1 << (BYTES_PER_LENGTH_OFFSET * 8)) - 1;
+#[cfg(target_pointer_width = "32")]
+pub const MAX_LENGTH_VALUE: usize = (std::u32::MAX >> 8 * (4 - BYTES_PER_LENGTH_OFFSET)) as usize;
+#[cfg(target_pointer_width = "64")]
+pub const MAX_LENGTH_VALUE: usize = (std::u64::MAX >> 8 * (8 - BYTES_PER_LENGTH_OFFSET)) as usize;
/// Convenience function to SSZ encode an object supporting ssz::Encode.
///
