Last active
October 10, 2022 18:55
-
-
Save DGriffin91/7a1cb8633dd17d4b43c985c7e239fc66 to your computer and use it in GitHub Desktop.
rkyv LLVM Invalid bitcast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compiling invalid-bitcast v0.1.0 | |
Invalid bitcast | |
%38 = bitcast <2 x i32> %37 to <2 x i24> | |
Invalid bitcast | |
%40 = bitcast <2 x i32> %39 to <2 x i24> | |
in function _ZN4rkyv5impls4core89_$LT$impl$u20$rkyv..DeserializeUnsized$LT$$u5b$U$u5d$$C$D$GT$$u20$for$u20$$u5b$T$u5d$$GT$19deserialize_unsized17h8bf3deadc9a4552bE | |
LLVM ERROR: Broken function found, compilation aborted! | |
error: could not compile `invalid-bitcast` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "invalid-bitcast" | |
version = "0.1.0" | |
edition = "2021" | |
license = "MIT OR Apache-2.0" | |
[dependencies] | |
rkyv = { version = "0.7", features = ["validation"] } | |
bytecheck = "0.6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use rkyv::{Archive, Deserialize, Serialize}; | |
use bytecheck::CheckBytes; | |
#[derive(Archive, Deserialize, Serialize, Clone, Eq, PartialEq, Default, Debug)] | |
#[archive(compare(PartialEq))] | |
#[archive_attr(derive(CheckBytes))] | |
pub struct Data(Vec<(u32, [u8; 3])>); | |
fn main() { | |
let mut actions = Data(vec![(0, [0, 0, 0])]); | |
let bytes = rkyv::to_bytes::<_, 128>(&actions).unwrap(); | |
if let Ok(archived) = rkyv::check_archived_root::<Data>(&bytes) { | |
if let Ok(deserialized) = archived.deserialize(&mut rkyv::Infallible) { | |
actions = deserialized; | |
} | |
} | |
dbg!(bytes, actions); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment