[Migrated] GEP not implemented for type struct [_; 0]

Open
#82 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
compilers

Research direction

Reproduce the failure from examples/shaders/compute-shader/src/lib.rs using the const-generic example with LENGTH = 0. Start by tracing the reported GEP handling for the zero-length array type, and consider the issue done when the example compiles without the “GEP not implemented” error while preserving the existing nonzero-length behavior.

Written by the indexing model from the issue text.

Description

Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/1075
Old labels: t: bug
Originally creatd by kevinboulain on 2023-06-16T09:49:20Z


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
Dominant language
Rust
Stars
3.4k
Forks
126
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Rust-GPU/rust-gpu

All issues in Rust-GPU/rust-gpu

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.