[Migrated] ZST's in structs cause invalid pointer casts
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.4k
- Forks
- 126
- PR merge metrics
- No merged PRs in 30d
Description
Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/1037
Old labels: t: bug,s: qptr may fix
Originally creatd by TrueDoctor on 2023-04-18T16:53:55Z
Expected Behaviour
The code should compile
Example & Steps To Reproduce
code:
#[spirv(fragment)]
pub fn main(x: (usize, ())) {
drop(&x.1);
}
result:
error: Cannot cast between pointer types
--> examples/shaders/simplest-shader/src/lib.rs:44:55
|
44 | #[spirv(fragment)] pub fn main(x: (usize, ())) { drop(&x.1); }
| ^^^^
|
= note: from: *u32
= note: to: *u8
error: Cannot offset a pointer to an arbitrary element
--> examples/shaders/simplest-shader/src/lib.rs:44:55
|
44 | #[spirv(fragment)] pub fn main(x: (usize, ())) { drop(&x.1); }
| ^^^^
error: Cannot cast between pointer types
--> examples/shaders/simplest-shader/src/lib.rs:44:50
|
44 | #[spirv(fragment)] pub fn main(x: (usize, ())) { drop(&x.1); }
| ^^^^^^^^^^
|
= note: from: *u8
= note: to: *struct () { }
System Info
- Rust: [e.g. 1.49.0-nightly (1eaadebb3 2020-10-21)]
- OS: linux 6.2.9-arch1-1
- GPU: Intel Iris Plus Graphics G7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproducer in examples/shaders/simplest-shader/src/lib.rs, especially the #[spirv(fragment)] function and the reference to x.1. Run the example and inspect the pointer-cast and arbitrary-offset errors. Done means this valid-looking struct containing a zero-sized tuple field compiles without those errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100