authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-23 19:01:33-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-23 19:01:51-04:00
log6a9c32f7597d37592d79afa27441e7caf9a30529
treed42bc9daf60782e8fb97abdcb46cc8bc20858be5
parent4d50bc3f8dd2b9fd5b7dde6f63f104aaba6dbf5a
signaturelock-open Commit is signed but in an unrecognized format.

add regression tests for a bug fixed by an older commit

closes #1914

2 files changed, 32 insertions(+), 0 deletions(-)

test/stage1/behavior.zig+1
......@@ -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 created+31
......@@ -0,0 +1,31 @@
1const std = @import("std");
2
3const A = struct {
4 b_list_pointer: *const []B,
5};
6const B = struct {
7 a_pointer: *const A,
8};
9
10const b_list: []B = []B{};
11const a = A{ .b_list_pointer = &b_list };
12
13test "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
19const A2 = struct {
20 pointer: *B,
21};
22
23pub const B2 = struct {
24 pointer_array: []*A2,
25};
26
27var b_value = B2{ .pointer_array = []*A2{} };
28
29test "basic stuff" {
30 std.debug.assert(&b_value == &b_value);
31}