zig/test/behavior/struct_contains_null_ptr_itself.zig
2023-05-11 20:31:52 +02:00

27 lines
666 B
Zig

const std = @import("std");
const expect = std.testing.expect;
const builtin = @import("builtin");
test "struct contains null pointer which contains original struct" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
var x: ?*NodeLineComment = null;
try expect(x == null);
}
pub const Node = struct {
id: Id,
comment: ?*NodeLineComment,
pub const Id = enum {
Root,
LineComment,
};
};
pub const NodeLineComment = struct {
base: Node,
};