-
Notifications
You must be signed in to change notification settings - Fork 249
GEP not implemented for type struct [_; 0] #1075
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
Comments
A slight modification of the previous example can also result in a division by zero in the compiler (can open another issue if you prefer): #![cfg_attr(target_arch = "spirv", no_std)]
use spirv_std::spirv;
fn example<const LENGTH: usize, R: Copy + Default>(callback: impl Fn() -> R) {
let mut array = [Default::default(); LENGTH];
for i in 0..array.len() {
array[i] = callback();
}
}
#[spirv(compute(threads(1, 1, 1)))]
pub fn compute() {
example::<10, ()>(|| ());
}
|
I also encountered the I'm not opening a PR though because I made that change blindly (I'm not familiar with the internals of rust-gpu and have no idea what's going on :), so I'm not confident that it's sound. |
Oh, that looks great! (I would only replace the panic but I haven't checked yet what's valid at that position) (sorry for not seeing this sooner, up until more recently the only way to guarantee I'd actually get notified would be to use |
This issue is now being tracked at: Rust-GPU/rust-gpu#82 |
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:
Resulting in:
System Info
The text was updated successfully, but these errors were encountered: