-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
integer overflow
with new for loop
#14700
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
It sounds a bit like a proposal? At the moment I think this is behaving as expected. |
I would definitely not expect the types to be padded out to edit: didnt realize it was going from 1 to 0 |
This is working as designed. You can't have a negative length. Note that if you make them
You also can't slice this way: const std = @import("std");
pub fn main() void {
const hello = "hello";
const start: u32 = 1;
const end: u32 = 0;
const slice = hello[start..end];
_ = slice;
}
with runtime known values:
|
Zig Version
0.11.0-dev.1711+dc1f50e50
Steps to Reproduce and Observed Behavior
output:
Expected Behavior
I would expect these two loops to behave equivalent:
And therefor no integer overflow should happen.
workaround for anyone else who stumbles over this
The text was updated successfully, but these errors were encountered: