Skip to content

returning a single-scalar #[repr(C)] struct causes PassMode::Cast and failure #373

Closed
@khyperia

Description

@khyperia

Originally reported in #361 (comment)

#[test]
fn struct_f32_return() {
    val(r#"
#[derive(Copy, Clone)]
#[repr(C)]
pub struct S {
    x: f32,
}
fn f() -> S { S { x: 2.0 } }
#[allow(unused_attributes)]
#[spirv(fragment)]
pub fn main() {
    f();
}
"#);
}
error: Cannot cast between pointer types
  --> src/lib.rs:14:29
   |
14 | fn f() -> S { S { x: 2.0 } }
   |                             ^
   |
   = note: from: *{Function} struct S { x: f32 }
   = note: to: *{Function} u32

error: Cannot cast between pointer types
  --> src/lib.rs:18:5
   |
18 |     f();
   |     ^^^
   |
   = note: from: *{Function} struct S { x: f32 }
   = note: to: *{Function} u32

Metadata

Metadata

Assignees

No one assigned

    Labels

    t: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions