-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Description
Inline functions
Please clarify in the language reference if this is illegal:
pub fn inline returnsLocal() *i32 {
var local: i32 = 0;
return &local;
}
Inline for
Please clarify in the language reference if this is illegal:
const std = @import("std");
pub fn main() void {
var bufs: [4]*const [4]u8 = undefined;
inline for (0..4) |i| {
const buf: [4]u8 = @splat(@intCast(i));
bufs[i] = &buf;
}
for (bufs) |buf| {
std.debug.print("{x}\n", .{buf});
}
}
00000000
01010101
02020202
03030303
Blocks
Please clarify in the language reference if this is illegal:
const std = @import("std");
pub fn main() void {
var x: *const i32 = &0;
{
var y: i32 = 1;
x = &y;
}
std.debug.print("x = {}\n", .{x.*});
}
x = 1
Related community thread: https://ziggit.dev/t/exploiting-inline-for-to-avoid-stack-curruption/8697/5
190n, leecannon, rootbeer, nektro, castholm and 2 more
Metadata
Metadata
Assignees
Labels
No labels