Skip to content

Commit 6a9c32f

Browse files
committed
add regression tests for a bug fixed by an older commit
closes #1914
1 parent 4d50bc3 commit 6a9c32f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

test/stage1/behavior.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ comptime {
2020
_ = @import("behavior/bugs/1486.zig");
2121
_ = @import("behavior/bugs/1500.zig");
2222
_ = @import("behavior/bugs/1851.zig");
23+
_ = @import("behavior/bugs/1914.zig");
2324
_ = @import("behavior/bugs/2006.zig");
2425
_ = @import("behavior/bugs/394.zig");
2526
_ = @import("behavior/bugs/421.zig");

test/stage1/behavior/bugs/1914.zig

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const std = @import("std");
2+
3+
const A = struct {
4+
b_list_pointer: *const []B,
5+
};
6+
const B = struct {
7+
a_pointer: *const A,
8+
};
9+
10+
const b_list: []B = []B{};
11+
const a = A{ .b_list_pointer = &b_list };
12+
13+
test "segfault bug" {
14+
const assert = std.debug.assert;
15+
const obj = B{ .a_pointer = &a };
16+
assert(obj.a_pointer == &a); // this makes zig crash
17+
}
18+
19+
const A2 = struct {
20+
pointer: *B,
21+
};
22+
23+
pub const B2 = struct {
24+
pointer_array: []*A2,
25+
};
26+
27+
var b_value = B2{ .pointer_array = []*A2{} };
28+
29+
test "basic stuff" {
30+
std.debug.assert(&b_value == &b_value);
31+
}

0 commit comments

Comments
 (0)