You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting unaligned_references warnings using serde_derive on packed structures. From #1747 and #1813 it seems like this should have been fixed since these structures also impl's Copy.
Here's a minimal example that reproduces what I'm seeing w/ serde 1.0.127
use serde;mod other {#[repr(C, packed)]#[derive(Debug,Copy,Clone,PartialEq,Default)]pubstructparamval<'a>{pubval_or_len:i32,pubplaces:u8,pubtype_:u8,pubbuf:&'a [u8],}}#[derive(serde::Serialize, serde::Deserialize)]#[serde(remote = "other::paramval")]structParamVal<'a>{val_or_len:i32,places:u8,type_:u8,buf:&'a [u8]}fnmain(){}
cargo build
⣿
Standard Error
Compiling playground v0.0.1 (/playground)
warning: reference to packed field is unaligned
--> src/main.rs:15:10
|
15 |#[derive(serde::Serialize, serde::Deserialize)]| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(unaligned_references)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= note: this warning originates in the derive macro `serde::Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: reference to packed field is unaligned
--> src/main.rs:15:10
|
15 |#[derive(serde::Serialize, serde::Deserialize)]| ^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #82523 <https://github.com/rust-lang/rust/issues/82523>
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= note: this warning originates in the derive macro `serde::Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: struct is never constructed: `ParamVal`
--> src/main.rs:17:8
|
17 | struct ParamVal<'a> { | ^^^^^^^^ | = note: `#[warn(dead_code)]` on by defaultwarning: 3 warnings emitted Finished dev [unoptimized + debuginfo] target(s) in 1.09s Running `target/debug/playground`
The packed structures are generated using bindgen and represent data received via a serialport stream. I could drop the packed repr generation in bindgen but that would prevent other users from using direct memory transmutes if they wanted to skip over the serde bindings.
The text was updated successfully, but these errors were encountered:
I'm getting
unaligned_references
warnings usingserde_derive
on packed structures. From #1747 and #1813 it seems like this should have been fixed since these structures also impl'sCopy
.Here's a minimal example that reproduces what I'm seeing w/ serde 1.0.127
playground link
The packed structures are generated using bindgen and represent data received via a serialport stream. I could drop the
packed
repr generation in bindgen but that would prevent other users from using direct memory transmutes if they wanted to skip over the serde bindings.The text was updated successfully, but these errors were encountered: