-
Notifications
You must be signed in to change notification settings - Fork 0
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
Write Zig code to avoid some of bugs #30
Comments
https://news.ycombinator.com/item?id=17184729
Is it also true today? |
const std = @import("std");
pub fn main() !void {
var array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
const ptr = &array[20];
ptr.* += 1;
}
|
const std = @import("std");
pub fn main() !void {
var array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
const slice = array[2..20];
slice[1] += 1;
}
It causes a run-time error. |
https://ziglang.org/documentation/master/#Integer-Overflow If we capture compile time error, we need |
https://ziglang.org/documentation/master/#Division-by-Zero Or use |
https://ziglang.org/documentation/master/#Lifetime-and-Ownership Above means the Zig doesn't have lifetime such as Rust's. |
Umm... Finally we think that the Zig language is not suitable for this postmortem. |
No description provided.
The text was updated successfully, but these errors were encountered: