Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GEP not implemented for type struct [_; 0] #151

Open
Firestar99 opened this issue Nov 18, 2024 · 2 comments
Open

GEP not implemented for type struct [_; 0] #151

Firestar99 opened this issue Nov 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Firestar99
Copy link
Member

Firestar99 commented Nov 18, 2024

Original issue: EmbarkStudios/rust-gpu#1075

Expected Behaviour

This compiles fine with rustc (I guess this bit is probably eliminated?).

Example & Steps To Reproduce

I was using const generic parameters to determine the length of some arrays. At some point, a base case ended up declaring a zero-length array, like so:

#![cfg_attr(target_arch = "spirv", no_std)]
use spirv_std::spirv;

fn example<const LENGTH: usize>() {
    let mut array = [0; LENGTH];
    for i in 0..array.len() {
        array[i] += i;
    }
}

#[spirv(compute(threads(1, 1, 1)))]
pub fn compute() {
    example::<0>();
}

Resulting in:

error: GEP not implemented for type struct [usize; 0] {  }
 --> examples/shaders/compute-shader/src/lib.rs:7:9
  |
7 |         array[i] += i;
  |         ^^^^^^^^^^^^^

System Info

* rustc: 1.71.0-nightly (1a5f8bce7 2023-05-26)

* rust-gpu: [b2e5eb7](https://github.com/EmbarkStudios/rust-gpu/commit/b2e5eb75951545782b121665c20f9f1c66fe5bdd)
@Firestar99 Firestar99 added the bug Something isn't working label Nov 18, 2024
@JulianKnodt
Copy link

Is it alright if I check this out?

@Firestar99
Copy link
Member Author

Feel free to give it a try. This old patch won't be directly cherry-pickable due to some larger gep changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants