Open
Description
Normally using undefined
in a comparison produces a compiler error:
./foo.zig:9:9: error: use of undefined value here causes undefined behavior
if(1==undefined) return;
But when using "this one weird trick" (comparing an optional pointer struct field), there are no errors and it compiles and runs:
const std = @import("std");
const Foo = struct{ a: ?*u8 = undefined };
pub fn main() void {
var foo = Foo{};
if(foo.a == undefined) std.debug.print("foo.a is undef {}\n",.{foo.a});
}