The following strictly always is undefined behavior that Zig chooses to compile successfully:
Checking if a value is not equal to undefined:
pub fn deinit(this: *@This()) void {
if (this.context != undefined) {
this.allocator.destroy(this.context);
}
}
Checking if a value is equal to undefined:
pub fn deinit(this: *@This()) void {
if (this.context == undefined) {
this.allocator.destroy(this.context);
}
}
Why isn't this a compiler error?
The following strictly always is undefined behavior that Zig chooses to compile successfully:
Checking if a value is not equal to undefined:
Checking if a value is equal to undefined:
Why isn't this a compiler error?