-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Expected Behaviour
Can cast [f32; 5]
as Data { a: f32, b: [f32; 3], c: f32 }
Example & Steps To Reproduce
#[repr(C)]
#[derive(Clone, Copy)]
struct Data {
a: f32,
b: [f32; 3],
c: f32,
}
union DataOrArray {
arr: [f32; 5],
str: Data,
}
impl DataOrArray {
fn arr(self) -> [f32; 5] { unsafe { self.arr } }
fn new(arr: [f32; 5]) -> Self { Self { arr } }
}
in shader:
let dora = DataOrArray::new([0.0, 0.0, 0.0, 0.0, 0.0]);
let arr = dora.arr();
Produces:
error: cannot cast between pointer types
from `*struct types::Data { a: f32, b: [f32; 3], c: f32 }`
to `*[f32; 5]`
System Info
- Rust: rustc 1.84.0-nightly (b19329a37 2024-11-21)
- OS: MacOS 15.3.2
- GPU: M2 Max
- rust-gpu: 698f10a
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
LegNeato commentedon Apr 23, 2025
Can you try latest master? I landed 2f915a0 which fixed issues with a similar message (#46) and I think this is fixed by it too.
simensgreen commentedon Apr 24, 2025
Nope, even at commit 2f915a0 error still appears
simensgreen commentedon Apr 24, 2025
I tried trick it with
core::mem::transmute
:Error:
simensgreen commentedon Apr 24, 2025
I created repo to test this error, but it failed to compile #242
LegNeato commentedon Apr 24, 2025
Ok great, I'll take a look.
LegNeato commentedon May 21, 2025
Wasn't able to find the root cause. This is going to churn shortly with some bigger qptr work so I am hesitant to spend more time until that lands
simensgreen commentedon May 25, 2025
@LegNeato Perhaps I can assist you with the QPTR, but I require further information. Could you please elaborate on what it is and from where it originates?
Fix union field access by representing unions as structs in SPIR-V
Fix union field access by representing unions as structs in SPIR-V
Fix union field access by representing unions as structs
nazar-pc commentedon Jun 25, 2025
I have a simple example with an array that results in the same error:
Not sure if the root cause is the same, but it looks similar.
UPD: Tried #269 in its current state, same issue.
UPD2: Even simpler piece of code:
Fails with:
Both
data
andself.data
are[u32; 16]
.