aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/bugs/1914.zig
blob: 4ac2b929a2751aa014fd54f2f7c72cb3d07cd31b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const std = @import("std");
const builtin = @import("builtin");

const A = struct {
    b_list_pointer: *const []B,
};
const B = struct {
    a_pointer: *const A,
};

const b_list: []B = &[_]B{};
const a = A{ .b_list_pointer = &b_list };

test "segfault bug" {
    if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
    const assert = std.debug.assert;
    const obj = B{ .a_pointer = &a };
    assert(obj.a_pointer == &a); // this makes zig crash
}

const A2 = struct {
    pointer: *B,
};

pub const B2 = struct {
    pointer_array: []*A2,
};

var b_value = B2{ .pointer_array = &[_]*A2{} };

test "basic stuff" {
    if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
    std.debug.assert(&b_value == &b_value);
}