zig/test/behavior/bugs/2006.zig
Andrew Kelley 4d05f2ae5f remove zig_is_stage2 from @import("builtin")
Instead use the standarized option for communicating the
zig compiler backend at comptime, which is `zig_backend`. This was
introduced in commit 1c24ef0d0b09a12a1fe98056f2fc04de78a82df3.
2022-01-17 21:55:49 -07:00

20 lines
573 B
Zig

const std = @import("std");
const expect = std.testing.expect;
const S = struct {
p: *S,
};
test "bug 2006" {
var a: S = undefined;
a = S{ .p = undefined };
try expect(@sizeOf(S) != 0);
if (@import("builtin").zig_backend != .stage1) {
// It is an accepted proposal to make `@sizeOf` for pointers independent
// of whether the element type is zero bits.
// This language change has not been implemented in stage1.
try expect(@sizeOf(*void) == @sizeOf(*i32));
} else {
try expect(@sizeOf(*void) == 0);
}
}