GEP not implemented for type struct [_; 0]
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.4k
- Forks
- 126
- PR merge metrics
- No merged PRs in 30d
Description
Original issue: https://github.com/EmbarkStudios/rust-gpu/issues/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)
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 by reproducing the error from examples/shaders/compute-shader/src/lib.rs with the zero-length const-generic array and confirm the GEP failure. Trace the compiler path handling indexing of the reported struct [usize; 0] type. Done means the example compiles successfully without the GEP error and the behavior is covered by a regression test.
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
- 35/100