Rust-GPU/rust-cuda

could not compile `ntapi` (lib) due to 2 previous errors. error[E0793]: reference to packed field is unaligned

CrackAnna opened this issue · 1 comments

error[E0793]: reference to packed field is unaligned
--> C:\Users\liuyu.cargo\registry\src\mirrors.ustc.edu.cn-12df342d903acd47\ntapi-0.3.7\src\ntexapi.rs:2783:52
|
2783 | *tick_count.QuadPart_mut() = read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
= note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use read_unaligned/write_unaligned (loads and stores via *p must be properly aligned even when using raw pointers)

error[E0793]: reference to packed field is unaligned
--> C:\Users\liuyu.cargo\registry\src\mirrors.ustc.edu.cn-12df342d903acd47\ntapi-0.3.7\src\ntexapi.rs:2807:25
|
2807 | ((read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses
= note: creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use read_unaligned/write_unaligned (loads and stores via *p must be properly aligned even when using raw pointers)

Running cargo tree --workspace --target all --invert ntapi points to the path_tracer example pulling in ntapi (see output below).

ntapi v0.3.7
├── mio v0.7.14
│   ├── mio-misc v1.2.2
│   │   └── winit v0.25.0
│   │       ├── glutin v0.27.0
│   │       │   ├── glium v0.30.2
│   │       │   │   ├── imgui-glium-renderer v0.8.2
│   │       │   │   │   └── path_tracer v0.1.0 (C:\Users\jorge\Workspace\rust-cuda\examples\cuda\cpu\path_tracer)
│   │       │   │   └── path_tracer v0.1.0 (C:\Users\jorge\Workspace\rust-cuda\examples\cuda\cpu\path_tracer)
│   │       │   └── path_tracer v0.1.0 (C:\Users\jorge\Workspace\rust-cuda\examples\cuda\cpu\path_tracer)
│   │       └── imgui-winit-support v0.8.2
│   │           └── path_tracer v0.1.0 (C:\Users\jorge\Workspace\rust-cuda\examples\cuda\cpu\path_tracer)
│   └── winit v0.25.0 (*)
└── sysinfo v0.20.5
    └── path_tracer v0.1.0 (C:\Users\jorge\Workspace\rust-cuda\examples\cuda\cpu\path_tracer)