(no title)
alchemio | 9 months ago
```zig
const std = @import("std");
fn get_ptr() i32 { var a: i32 = 6; return &a; }
pub fn main() void {
var x: ?*i32 = undefined;
{
var a: i32 = 5;
x.? = &a;
}
std.debug.print("{} {}", .{ x.?.*, get_ptr().* });
}``` These are trivial examples that Zig doesn’t even warn about, even though similar code in C or C++ gets a warning in gcc and clang.
This discussion:
https://ziggit.dev/t/what-makes-ban-returning-pointer-to-sta...
indicates that core zig devs aren’t interested in diagnosing such usage.
No comments yet.